/ Published in: HTML
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" /> <title> Linkpipe: Upstream Manholes </title> <script src= "http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"> </script> </head> <body onunload="GUnload()"> <h3> Linkpipe: Upstream Manholes </h3> <table border="1"> <tr> <td> <form name="dd" id="dd"> <select name="priority" onChange="setPriority(this);"> <option value="-1" selected="selected"> Select Priority </option> <option value="3"> High </option> <option value="2"> Medium </option> <option value="1"> Low </option> <option value="0"> CCTV </option> </select> </form> </td> </tr> <tr> <td> </td> <td width="150" valign="top" style= "text-decoration: none; color: #4444ff;"> <div id="side_bar" style= "overflow:auto; height:700px; font-size:10px;font-family:Arial;text-decoration:none;"> </div> </td> </tr> //<![CDATA[ if (GBrowserIsCompatible()) { var side_bar_html = ""; var gmarkers = []; var htmls = []; var i = 0; var priority = []; // A function to create the marker and set up the event window function createMarker(point,name,html) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); // save the info we need to use later for the side_bar gmarkers.push(marker); // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + (gmarkers.length-1) + ')">' + name + '<\/a><br>'; return marker; } // This function picks up the click and opens the corresponding info window function myclick(i) { GEvent.trigger(gmarkers[i], "click"); } // create the map var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(33.9033, -118.2418), 10); GDownloadUrl("linkpipe2.xml", function(doc) { var xmlDoc; function setPriority(dd) { map.clearOverlays(); var selectedPriority = dd.value;       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 html = markers[i].getAttribute("label");         var label = markers[i].getAttribute("label");         var priority = markers[i].getAttribute("priority");         // create the marker         //If the selected priority == -1 then display all         if (priority==selectedPriority || selectedPriority==-1) {         var marker = createMarker(point,label,html);         map.addOverlay(marker);         } // GDownloadUrl("linkpipe2.xml", function(doc) { // xmlDoc = GXml.parse(doc);       }       // put the assembled side_bar_html contents into the side_bar div       document.getElementById("side_bar").innerHTML = side_bar_html; } } ) else { alert("Sorry, the Google Maps API is not compatible with this browser"); } //]]> </script> </body> </html>