<!doctype html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style> html { height: 100% } body { height: 100%; margin: 0; padding: 0; background-color: #FFF } #map_canvas { height: 100% } </style> <script src="../artDialog.source.js"></script> <script src="../plugins/iframeTools.source.js"></script> <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=zh_CN"></script> <script> var map, geocoder; function initialize() { var latlng = new google.maps.LatLng(39.904214, 116.407413); var options = { zoom: 11, center: latlng, disableDefaultUI: true, panControl: true, zoomControl: true, mapTypeControl: true, scaleControl: true, streetViewControl: false, overviewMapControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), options); geocoder = new google.maps.Geocoder(); geocoder.geocode({latLng: latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[3]) { document.getElementById("map_address").value = results[3].formatted_address; } } }); var dialog = art.dialog.open.api; dialog.title('google mpas') .size(558, 360) .button({name: '截图', callback: function () { var center = map.getCenter().lat() + ',' + map.getCenter().lng(), zoom = map.getZoom(), maptype = map.getMapTypeId(), url = 'http://maps.googleapis.com/maps/api/staticmap'; url += '?center=' + encodeURIComponent(center); url += '&zoom=' + encodeURIComponent(zoom); url += '&size=558x360'; url += '&maptype=' + encodeURIComponent(maptype); url += '&markers=' + encodeURIComponent(center); url += '&language=zh_CN'; url += '&sensor=false'; art.dialog.through({title: false, content: '<img src="' + url + '" />', padding: 0, width: 558, height: 360, lock: true}); return false; }, focus: true}) .position('50%', 'goldenRatio'); document.getElementById("map-search-sumbit").onclick = function () { var input = document.getElementById('map_address'); search(input.value); }; } function search(address) { if (!map) return; geocoder.geocode({address : address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setZoom(11); map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert("Invalid address: " + address); } }); } </script> </head> <body onload="initialize();" style="font: 12px/1.11 'Microsoft Yahei', Tahoma, Arial, Helvetica, STHeiti; _font-family:Tahoma,Arial,Helvetica,STHeiti; -o-font-family: Tahoma, Arial;"> <div style="width:100%; height:100%"> <table style="width:100%;height:100%;"> <tr> <td style="height:38px"><div style="margin:5px;">地址: <input id="map_address" value="" style="width:200px; padding:4px;"> <button id="map-search-sumbit">搜 索</button></div></td> </tr> <tr> <td style="height:100%"><div id="map_canvas" style="height:100%; margin:0 5px"></div></td> </tr> </table> </div> </body> </html>