Hello,
I'm having a problem with zomming to the map dynamically. At first it
worked just fine but later on it didn't work anymore. When I ad the
alert (now in comment) it works but like my code is now, it doesn't.
Can someone tell me why?
Javascriptcode:
var map;
function initialize() {
if (GBrowserIsCompatible()) {
map = new google.maps.Map2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GOverviewMapControl());
map.enableScrollWheelZoom();
map.addControl(new GScaleControl());
map.setMapType(G_NORMAL_MAP);
var mgr = new google.maps.MarkerManager(map);
map.setCenter(new GLatLng(0, 0), 0);
var tmp = getMarkers();
mgr.addMarkers(tmp.batch, 0);
mgr.refresh();
bounds = tmp.bounds;
//alert("echo");
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
}
function getMarkers() {
var batch = [];
var bounds = new GLatLngBounds();
GDownloadUrl('./xml/Points.xml', function don(Points) {
var xml = GXml.parse(Points);
var markers = xml.documentElement.getElementsByTagName
("marker");
for (var i = 0; i < markers.length; i++) {
var point = new google.maps.LatLng(markers[i].getAttribute
("lati"), markers[i].getAttribute("longi"));
var marker = new GMarker(point);
var address = markers[i].getAttribute("city") + ", " +
markers[i].getAttribute("country") + " (" + markers[i].getAttribute
("countryCode") + ")";
addEvent(marker, point, address, markers[i].getAttribute
("responses"));
bounds.extend(point);
batch.push(marker);
}
});
return { batch: batch, bounds: bounds };
}
function addEvent(marker, point, text, respons) {
GEvent.addListener(marker, "click", function() {
var myHtml = text + "<br/>Results: " + respons;
map.openInfoWindowHtml(point, myHtml);
}
);
}
example of the XML-file:
<markers>
<marker
country="Russie"
countryCode="RU"
city="Moscow"
lati="55.7522010803223"
longi="37.6156005859375"
responses="1" />
<marker
country="Royaume-Uni"
countryCode="GB"
city="Falkirk"
lati="56"
longi="-3.76679992675781"
responses="5" />
<marker
country="Belgique"
countryCode="BE"
city="Brussels"
lati="50.8333015441895"
longi="4.33330011367798"
responses="2" />
</markers>
I'm hoping for an answer!
Greetz.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---