diff options
Diffstat (limited to 'examples/declarative/webview/content/Mapping')
-rw-r--r-- | examples/declarative/webview/content/Mapping/Map.qml | 40 | ||||
-rwxr-xr-x | examples/declarative/webview/content/Mapping/map.html | 94 |
2 files changed, 67 insertions, 67 deletions
diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index aae6b5d..2e98940 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -1,20 +1,20 @@ -import Qt 4.6
-
-Item {
- id: page
- property real latitude: -34.397
- property real longitude: 150.644
- property string address: ""
- WebView {
- id: map
- anchors.fill: parent
- url: "map.html"
- javaScriptWindowObjects: QtObject {
- WebView.windowObjectName: "qml"
- property real lat: page.latitude
- property real lng: page.longitude
- property string address: page.address
- onAddressChanged: {map.evaluateJavaScript("goToAddress()")}
- }
- }
-}
+import Qt 4.6 + +Item { + id: page + property real latitude: -34.397 + property real longitude: 150.644 + property string address: "" + WebView { + id: map + anchors.fill: parent + url: "map.html" + javaScriptWindowObjects: QtObject { + WebView.windowObjectName: "qml" + property real lat: page.latitude + property real lng: page.longitude + property string address: page.address + onAddressChanged: {map.evaluateJavaScript("goToAddress()")} + } + } +} diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html index 8afa21c..72f426a 100755 --- a/examples/declarative/webview/content/Mapping/map.html +++ b/examples/declarative/webview/content/Mapping/map.html @@ -1,47 +1,47 @@ -<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()
- geocoder.geocode(req, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK)
- goToLatLng(results[0].geometry.location,results[0].geometry.bounds);
- });
- }
- }
-</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>
+<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() + geocoder.geocode(req, function(results, status) { + if (status == google.maps.GeocoderStatus.OK) + goToLatLng(results[0].geometry.location,results[0].geometry.bounds); + }); + } + } +</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> |