map.html 2.2 KB

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