You might be interested in this code to read the KML (XML) file, it
work excellent for me, but it does have a limitation of about 470
markers, why I don't know.
<html>
<head>
<script type="text/javascript">
function onload_gmap(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {window.onload = func;} else
{
window.onload = function() {if (oldonload){oldonload();}func();}
}
}
function format_gmap(map, control, maptype, show_marker, addoverview,
addscale, addgoogle) {
if (control!='') {
var controls = control.split('|');
for (i=0; i<controls.length; ++i) {eval('map.addControl(new
'+controls[i]+'());');}
}
if (maptype!='') {eval('map.setMapType('+maptype+');');}
if (control=='' && maptype=='') {map.setUIToDefault();}
if (addoverview=='1') map.addControl(new GOverviewMapControl());
if (addscale=='1') map.addControl(new GScaleControl());
if (addgoogle=='1') map.enableGoogleBar();
}
</script>
<script src="http://maps.google.com/maps?
file=api&v=2&key=ABQIAAAAg5a8HqfsjpIglfTazdfPwhR44WSwzKZNFwLbseJiV8uGMUG7KBQh-
CW6Nt9sh5aOLgUFPzo03taNeA" type="text/javascript">
</script>
<script type="text/javascript">
function init_gmap_gmap(id, addr, centerLatitude, centerLongitude,
startZoom, description, kml, control, maptype, show_marker,
addoverview, addscale, addgoogle) {
if (addr!='') {
geocoder = new GClientGeocoder();
geocoder.getLatLng(addr, function(pt) {
if (pt == null) {
var mapdiv = document.getElementById("gmap_gmap"+id);
mapdiv.innerHTML = '<p style="background:#ffff00">Google
cannot find the address you specified: <b>'+addr+'</b><br />Please
double check your address.</p><ul><li>Please make sure you enter the
full address in double quotes.</li><li>For countries other than US,
please do not forget to enter the country name.</li></ul><p>Click here
for <a href="http://gmaps-samples.googlecode.com/svn/trunk/
mapcoverage_filtered.html">full list of supported countries</a>.</p>';
} else {
display_gmap_gmap(id, pt.lat(), pt.lng(), startZoom,
description,
kml, control, maptype, show_marker, addoverview, addscale, addgoogle);
}
});
} else {
display_gmap_gmap(id, centerLatitude, centerLongitude,
startZoom, description, kml, control, maptype, show_marker,
addoverview, addscale, addgoogle);
}
}
function display_gmap_gmap(id, centerLatitude, centerLongitude,
startZoom, description, kml, control, maptype, show_marker,
addoverview, addscale, addgoogle) {
var mapdiv = document.getElementById("gmap_gmap"+id);
if (GBrowserIsCompatible()) {
var map = new GMap2(mapdiv);
map.setCenter(new GLatLng(centerLatitude, centerLongitude),
startZoom);
if (kml!='') {
var gx = new GGeoXml(kml);
map.addOverlay(gx);
} else {
if (show_marker) {
var MyIcon = new GIcon(); // create a new
Google Icon object
MyIcon.image = "http://www.domain.com/
image_file_for_marker.png";// image file name
MyIcon.shadow = "images/sm_shadow.png";//
shadow file name
MyIcon.iconSize = new GSize(10, 30);// width
(px) and height (px)
MyIcon.shadowSize = new GSize(20, 30);// the
shadow's size
MyIcon.iconAnchor = new GPoint(6, 20);// base
of the icon
MyIcon.iconWindowAnchor = new GPoint(0, 0);//
info window base
var marker = new GMarker(new
GLatLng(centerLatitude,
centerLongitude), MyIcon);
//if (description!='')
{GEvent.addListener(marker, 'click',
function() {marker.openInfoWindowHtml(description);});}
if (description!='')
{GEvent.addListener(marker, "mouseover",
function() {marker.openInfoWindowHtml(description);});}
map.addOverlay(marker);
}
}
format_gmap(map, control, maptype, show_marker, addoverview,
addscale, addgoogle);
} else {
mapdiv.innerHTML = 'Sorry, your browser is not compatible with
Google Maps.';
}
}
</script>
</head>
<body>
<script type="text/javascript">
function load_gmap() {
init_gmap_gmap('0', '', 37.4219720, -122.0841430, 12, '', 'http://
www.domain.com/test.kml?39', '', '', false, '', '1', '0');
}
onload_gmap(load_gmap);
window.onunload = GUnload;
</script>
<div id="gmap_gmap0" style="width: 800px; height: 480px"></div>
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---