map.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <style>
  6. html { height: 100% }
  7. body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
  8. #map_canvas { height: 100% }
  9. </style>
  10. <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=zh_CN"></script>
  11. <script>
  12. var map, geocoder;
  13. function initialize() {
  14. var latlng = new google.maps.LatLng(-34.397, 150.644);
  15. var options = {
  16. zoom: 11,
  17. center: latlng,
  18. disableDefaultUI: true,
  19. panControl: true,
  20. zoomControl: true,
  21. mapTypeControl: true,
  22. scaleControl: true,
  23. streetViewControl: false,
  24. overviewMapControl: true,
  25. mapTypeId: google.maps.MapTypeId.ROADMAP
  26. };
  27. map = new google.maps.Map(document.getElementById("map_canvas"), options);
  28. geocoder = new google.maps.Geocoder();
  29. geocoder.geocode({latLng: latlng}, function(results, status) {
  30. if (status == google.maps.GeocoderStatus.OK) {
  31. if (results[3]) {
  32. parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;
  33. }
  34. }
  35. });
  36. }
  37. function search(address) {
  38. if (!map) return;
  39. geocoder.geocode({address : address}, function(results, status) {
  40. if (status == google.maps.GeocoderStatus.OK) {
  41. map.setZoom(11);
  42. map.setCenter(results[0].geometry.location);
  43. var marker = new google.maps.Marker({
  44. map: map,
  45. position: results[0].geometry.location
  46. });
  47. } else {
  48. alert("Invalid address: " + address);
  49. }
  50. });
  51. }
  52. </script>
  53. </head>
  54. <body onload="initialize();">
  55. <div id="map_canvas" style="width:100%; height:100%"></div>
  56. </body>
  57. </html>