examples/declarative/modelviews/webview/content/Mapping/map.html
changeset 30 5dc02b23752f
child 33 3e2da88830cd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/declarative/modelviews/webview/content/Mapping/map.html	Tue Jul 06 15:10:48 2010 +0300
@@ -0,0 +1,52 @@
+<html>
+<head>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+<script type="text/javascript">
+  var geocoder
+  var map
+  function goToLatLng(latlng,bounds) {
+    if (map) {
+        map.setCenter(latlng)
+        map.fitBounds(bounds)
+    } else {
+        var myOptions = {
+          zoom: 8,
+          center: latlng,
+          mapTypeId: google.maps.MapTypeId.ROADMAP
+        };
+        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+    }
+  }
+  function initialize() {
+    geocoder = new google.maps.Geocoder();
+    if (window.qml.address) {
+        goToAddress()
+    } else {
+        goToLatLng(new google.maps.LatLng(window.qml.lat,window.qml.lng));
+    }
+  }
+  function goToAddress() {
+      if (geocoder) {
+        var req = {
+            address: window.qml.address,
+        }
+        if (map)
+            req.bounds = map.getBounds()
+        window.qml.status = "Loading";
+        geocoder.geocode(req, function(results, status) {
+          if (status == google.maps.GeocoderStatus.OK) {
+            window.qml.status = "Ready";
+            goToLatLng(results[0].geometry.location,results[0].geometry.bounds);
+          } else {
+            window.qml.status = "Error";
+          }
+        });
+      }
+  }
+</script>
+</head>
+<body onload="initialize()" leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px">
+  <div id="map_canvas" style="width:100%; height:100%"></div>
+</body>
+</html>