Mike, thanks for the comments, have had a lot of help from your
website during creation of my map. As I am new to building websites my
code is a lot of copy, cut and paste. Thanks for the guide.
So I tried to get the stuff to load only when clicked by changing te
following into what stands below. This isn't working, what am i doing
wrong?
====================================================
code as it is slow
====================================================
function addMarkers() {
// Add the cluster marker
GDownloadUrl("mapfunct/marker/xmlmarkers2.php", function (doc)
{
var xmlDoc = GXml.parse(doc);
var cmarkers = xmlDoc.documentElement.getElementsByTagName
("country_marker");
for (var i = 0; i < cmarkers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(cmarkers[i].getAttribute("lat"));
var lng = parseFloat(cmarkers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var zoom = cmarkers[i].getAttribute("zoom");
var marker = new GMarker(point,clusterIcon);
var minZoom = mapZoom - 4;
var maxZoom = mapZoom + 1;
var name = cmarkers[i].getAttribute("country");
var type = cmarkers[i].getAttribute("type");
markerMgr.addMarker(marker,minZoom,maxZoom);
addClusterListeners(marker,lat,lng,zoom);
}
var markers =[]
var tmarkers = xmlDoc.documentElement.getElementsByTagName
("track_markers");
for (var i = 0; i < tmarkers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(tmarkers[i].getAttribute("lat"));
var lng = parseFloat(tmarkers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var name = tmarkers[i].getAttribute("htmllarge");
var type = tmarkers[i].getAttribute("country");
var marker = new GMarker(point,greenIcon);
markers.push(marker);
addListeners(marker, name)
}
var minZoom = mapZoom + 2;
markerMgr.addMarkers(markers,minZoom);
});
}
// function to add listeners for the markers
function addListeners(marker, name) {
GEvent.addListener(marker, "click", function() {
map.closeInfoWindow();
var textHTML = name;
marker.openInfoWindowHtml(textHTML);
});
return marker;
}
// Function to save the map context via the DragZoomControl method
and then zoom in to the (lat,lng)
// called when the cluster marker is clicked
function addClusterListeners(marker, lat, lng, zoom) {
GEvent.addListener(marker, "click", function() {
map.closeInfoWindow();
DragZoom.saveMapContext('Cluster Zoom Back');
map.setCenter(new GLatLng(lat,lng),parseInt(zoom));
}
)
return marker;
}
// Function called after the map context is restored from the
cluster zoom
// This callback clears the infoWindow if it is open
function restoreContextCallback(method) {
if (method) map.closeInfoWindow(); // "method" indicates
this particular restore was for
} // a zoom called by the
method, not the regular DragZoom
===================================================================
This is the bit I changed. (left the code above and below this part
the same)
===================================================================
// obtain the attribues of each marker
var lat = parseFloat(tmarkers[i].getAttribute("lat"));
var lng = parseFloat(tmarkers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var marker.myhtml = tmarkers[i].getAttribute("htmllarge");
var type = tmarkers[i].getAttribute("country");
var marker = new GMarker(point,greenIcon);
markers.push(marker);
addListeners(marker, name)
}
var minZoom = mapZoom + 2;
markerMgr.addMarkers(markers,minZoom);
});
}
// function to add listeners for the markers
function addListeners(marker, name) {
GEvent.addListener(map, "click", function(overlay, point) {
if (overlay) {
if (overlay.myhtml) {
overlay.openInfoWindowHtml(overlay.myhtml);
}
}
});
return marker;
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---