ÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps</title> <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKxtG-zsg5gA5ZWbCTC9hyRRmedYzjG9eXi1GFfzGWkd9jJADwhThbwBaPpkRRs0U8dWsd15ShJhJKg" type="text/javascript"></script> </head> <body onunload="GUnload()"> <!-- you can use tables or divs for the overall layout --> <table border=0> <tr> <td> <div id="map" style="width: 1060px; height: 840px"></div> </td> </tr> </table> <noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b> However, it seems JavaScript is either disabled or not supported by your browser. To view Google Maps, enable JavaScript by changing your browser options, and then try again. </noscript> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { // this variable will collect the html which will eventualkly be placed in the side_bar var side_bar_html = ""; // arrays to hold copies of the markers and html used by the side_bar // because the function closure trick doesnt work there var gmarkers = []; var htmls = []; var i = 0; // Create our "tiny" marker icon var icon = new GIcon(); icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(12, 20); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(6, 20); icon.infoWindowAnchor = new GPoint(5, 1); // A function to create the marker and set up the event window function createMarker(point,name,html,icon) { var marker = new GMarker(point,icon); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); // save the info we need to use later for the side_bar gmarkers[i] = marker; htmls[i] = html; // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + i + ')">' + html + '</a><br>'; i++; return marker; } // This function picks up the click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } // create the map var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng( 56.000000,10.500000), 10); // Read the data from example.xml var request = GXmlHttp.create(); request.open("GET", "example.xml", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; // obtain the array of markers and loop through it var markers = xmlDoc.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var navn = markers[i].getAttribute("navn"); var adresse = markers[i].getAttribute("adresse"); var postnr = markers[i].getAttribute("postnr"); var by = markers[i].getAttribute("by"); var tlf1 = markers[i].getAttribute("tlf1"); var tlf2 = markers[i].getAttribute("tlf2"); var html = '<b>'+navn+'</b><br>'+adresse+'<br>'+postnr+' '+by+'<br>'+tlf1+'<br>'+tlf2; var label = markers[i].getAttribute("label"); var marker = createMarker(point,label,'<div style="background-color:#e6e6e6; font-family:verdana; font-size:10px;" >'+html+'</div>',icon); map.addOverlay(marker); } } } request.send(null); } else { alert("Sorry, the Google Maps API is not compatible with this browser"); } //]]> </script> </body> </html>