Root/
| Source at commit HEAD created 3 months 18 days ago. By marcocantu, This is the long awaited and much requested GoogleMappingDemo project, which let's you view a Google Map within a Delphi application (using a TWebBrowser control connected to the Indy Web Server embedded in the same program). Needs Google maps developer key. | |
|---|---|
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="content-type" content="text/html; charset=utf-8"/> |
| 6 | <title>Marco's Google Maps Example</title> |
| 7 | <script src="http://maps.google.com/maps?file=api&v=2&key=[devkey]" |
| 8 | type="text/javascript"></script> |
| 9 | <script type="text/javascript"> |
| 10 | |
| 11 | //<![CDATA[ |
| 12 | |
| 13 | function load() { |
| 14 | if (GBrowserIsCompatible()) { |
| 15 | var map = new GMap2(document.getElementById("map")); |
| 16 | map.addControl(new GMapTypeControl()); |
| 17 | map.addControl(new GSmallMapControl()); |
| 18 | map.setCenter(new GLatLng(37.0625, -95.677068), 4); |
| 19 | |
| 20 | // Creates a marker at the given point with the given number label |
| 21 | function createMarker(point, description) { |
| 22 | var marker = new GMarker(point); |
| 23 | GEvent.addListener(marker, "click", function() { |
| 24 | marker.openInfoWindowHtml("There are <b>" + description + "</b>"); |
| 25 | }); |
| 26 | return marker; |
| 27 | } |
| 28 | |
| 29 | var point = new GLatLng(45.0282, 9.6865); |
| 30 | map.addOverlay(new createMarker(point, "Piacenza")); |
| 31 | GDownloadUrl("/map.xml" ,function(data, responseCode) { |
| 32 | var xml = GXml.parse(data); |
| 33 | var markers = xml.documentElement.getElementsByTagName("pos"); |
| 34 | for (var i = 0; i < markers.length; i++) { |
| 35 | var point = new GLatLng(parseFloat(markers[i].getAttribute("l")), |
| 36 | parseFloat(markers[i].getAttribute("o"))); |
| 37 | map.addOverlay(new createMarker(point, markers[i].getAttribute("n"))); |
| 38 | }}) |
| 39 | |
| 40 | } |
| 41 | } |
| 42 | //]]> |
| 43 | </script> |
| 44 | </head> |
| 45 | <body onload="load()" onunload="GUnload()"> |
| 46 | <h2>Google Maps Example</h2> |
| 47 | <p>Cities</p> |
| 48 | <div id="map" style="width: 650px; height: 450px"></div> |
| 49 | </body> |
| 50 | </html> |
