Hello all. I'm working with a map that can be viewed at:
http://www.indianasheep.com/pages/map.php. On this map, I'm going to
be showing businesses that fall under multiple categories. Currently,
I just have 2 categories...suppliers and producers. Each category has
a different colored marker and by default, the map loads all of the
markers for all businesses. What I'd like to do is make links on the
right navigation bar that allows a user to display only those markers
associated with producers, for example.

I assume I can just pass a variable in the url (for use in php GET
function) that would tell the map to only show markers associated with
businesses in that category. However, I'm having trouble implementing
this scheme.

Following is the code I currently have for displaying the map:

----------------------------------------------------------------

                var iconRed = new GIcon();
                iconRed.image = 'images/mapmarker1.gif';
                iconRed.iconSize = new GSize(12, 12);
                iconRed.iconAnchor = new GPoint(0, 0);
                iconRed.infoWindowAnchor = new GPoint(5, 0);

                var iconBlue = new GIcon();
                iconBlue.image = 'images/mapmarker2.gif';
                iconBlue.iconSize = new GSize(12, 12);
                iconBlue.iconAnchor = new GPoint(0, 0);
                iconBlue.infoWindowAnchor = new GPoint(5, 0);

                var chooseIcon = [];
                chooseIcon["producer"] = iconRed;
                chooseIcon["supplier"] = iconBlue;

                function load() {
                  if (GBrowserIsCompatible()) {
                        var htmls = [];
                        var idmarkers = [];
                        var i = 0;
                        var id = -1;

                        var query = location.search.substring(1);
                        var pairs = query.split("&");
                        for (var i=0; i<pairs.length; i++) {
                                var pos = pairs[i].indexOf("=");
                                var argname = 
pairs[i].substring(0,pos).toLowerCase();
                                var value = 
pairs[i].substring(pos+1).toLowerCase();
                                if (argname == "id") {id = parseFloat(value);}
                        }

                        function createMarker(point, member, membertype, 
firstname1,
lastname1, firstname2, lastname2, address1, address2, city, state,
zip, phone1, phone2, fax, email, website) {
                                var marker = new GMarker(point, 
chooseIcon[membertype]);
                                var html = "<b>" + member + "</b><br/>" + 
((firstname1!=null &&
lastname1!=null)?firstname1+" "+lastname1:"") + ((firstname2!=null &&
lastname2!=null)?firstname2+" "+lastname2:"") + ((address1!=null)?"<br/
>"+address1:"") + ((address2!=null)?"<br/>"+address2:"") + ((city!
=null && state!=null && zip!=null)?"<br/>"+city+", "+state+" "+zip:"")
+ ((phone1!=null)?"<br/>Phone: "+phone1:"") + ((phone2!=null)?"<br/
>Phone 2: "+phone2:"") + ((fax!=null)?"<br/>Fax: "+fax:"") + ((email!
=null)?"<br/>"+email:"") + ((website!=null)?"<br/>"+website:"");
                                GEvent.addListener(marker, 'click', function()
{ marker.openInfoWindowHtml(html); });
                                htmls[i] = html;
                        idmarkers[i] = marker;
                                i++;
                                return marker;
                        }

                        var map = new GMap2(document.getElementById("map"));
                        map.enableScrollWheelZoom();
                        map.addControl(new GLargeMapControl());
                        map.addControl(new GMapTypeControl());
                        map.addControl(new GScaleControl());
                        map.setCenter(new GLatLng(39.810446, -86.163341), 7,
G_NORMAL_MAP);

                        GDownloadUrl("scripts/markers.php", function(data) {
                          var xml = GXml.parse(data);
                          var markers = 
xml.documentElement.getElementsByTagName("marker");
                          for (var i = 0; i < markers.length; i++) {
                                var member = markers[i].getAttribute("member");
                                var membertype = 
markers[i].getAttribute("membertype");
                                var firstname1 = 
markers[i].getAttribute("firstname1");
                                var lastname1 = 
markers[i].getAttribute("lastname1");
                                var firstname2 = 
markers[i].getAttribute("firstname2");
                                var lastname2 = 
markers[i].getAttribute("lastname2");
                                var address1 = 
markers[i].getAttribute("address1");
                                var address2 = 
markers[i].getAttribute("address2");
                                var city = markers[i].getAttribute("city");
                                var state = markers[i].getAttribute("state");
                                var zip = markers[i].getAttribute("zip");
                                var phone1 = markers[i].getAttribute("phone1");
                                var phone2 = markers[i].getAttribute("phone2");
                                var fax = markers[i].getAttribute("fax");
                                var email = markers[i].getAttribute("email");
                                var website = 
markers[i].getAttribute("website");
                                var point = new 
GLatLng(parseFloat(markers[i].getAttribute
("lat")),
                                                                                
parseFloat(markers[i].getAttribute("lon")));
                                var marker = createMarker(point, member, 
membertype, firstname1,
lastname1, firstname2, lastname2, address1, address2, city, state,
zip, phone1, phone2, fax, email, website);
                                map.addOverlay(marker);
                          }
                        });
                  }
                }

------------------------------------------------

Any help is greatly appreciated. I'm sure this is an easy fix, but I
haven't been able to make much progress up to this point.

Thanks!

Ryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to