Hi all:

I was going to make markers with custom icons those are created
dynamicly by parsing a XML. The markers were created correctly having
their icons, but the map cannot focus the marker when it was clicked
to open an infowindow. Once upon the marker opens the infowindow, the
map shifts to another place where is not the marker and changes the
zoom level. Here is the demo link:

http://www.nomadgreen.org/?page_id=135

---
My procedure to create custom icon marker is as follow:

1. declare a global icon array outside the js funtions
2. use a function to parse xml, create custom icons, and assign them
to the global icon array with String index.
3. create markers with custom icons from the global icon array, add
clicking event listener to markers, and add markers to the map.
4. open infowindow on the event of clicking the marker.
5. the map moves away from the marker opening infowindow, even goes
out of bound.

---
My script is as follow:

var customIcons = [];

function loadIcons(){
var searchUrl = root_url + 'geniconsxml.php' ;
GDownloadUrl(searchUrl, function(data) {
var xml = GXml.parse(data);
var icons = xml.documentElement.getElementsByTagName('icon');
for (var i = 0; i < icons.length; i++) {
        var icon_name = icons[i].getAttribute('icon_name');
        var icon_img = icons[i].getAttribute('icon_img');
        var icon_shadow_img = icons[i].getAttribute('icon_shadow_img');
        var icon_size_width = icons[i].getAttribute('icon_size_width');
        var icon_size_height = icons[i].getAttribute('icon_size_height');
        var shadow_size_width = icons[i].getAttribute('shadow_size_width');
        var shadow_size_height = icons[i].getAttribute('shadow_size_height');
        var icon_anchor_x = icons[i].getAttribute('icon_anchor_x');
        var icon_anchor_y = icons[i].getAttribute('icon_anchor_y');
        var infowindow_anchor_x = icons[i].getAttribute
('infowindow_anchor_x');
        var infowindow_anchor_y = icons[i].getAttribute
('infowindow_anchor_y');
        var icon = new GIcon();
        icon.image = root_url + "images/" + icon_img;
        icon.shadow = root_url + "images/" + icon_shadow_img;
        icon.iconSize = new GSize(icon_size_width, icon_size_height);
        icon.shadowSize = new GSize(shadow_size_width,shadow_size_height);
        icon.iconAnchor = new GPoint(icon_anchor_x, icon_anchor_y);
        icon.infoWindowAnchor = new GPoint(infowindow_anchor_x,
infowindow_anchor_y);
        customIcons[icon_name] = icon;
}
});

}

P.S. It works fine if I create each icon and set its properties
outside the function right after its declaration. But I have to do it
in the function because the icon data is
load from a dynamic XML.

Does anyone have the same problem? Help me please!!

--~--~---------~--~----~------------~-------~--~----~
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