map.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Baidu Maps</title>
  6. <style>
  7. html { height: 100% }
  8. body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
  9. </style>
  10. <script charset="utf-8" src="http://api.map.baidu.com/api?v=1.3"></script>
  11. <script>
  12. var map, geocoder;
  13. function initialize() {
  14. map = new BMap.Map('map_canvas');
  15. var point = new BMap.Point(121.473704, 31.230393);
  16. map.centerAndZoom(point, 11);
  17. map.addControl(new BMap.NavigationControl());
  18. map.enableScrollWheelZoom();
  19. var gc = new BMap.Geocoder();
  20. gc.getLocation(point, function(rs){
  21. var addComp = rs.addressComponents;
  22. var address = [addComp.city].join('');
  23. parent.document.getElementById("kindeditor_plugin_map_address").value = address;
  24. });
  25. }
  26. function search(address) {
  27. if (!map) return;
  28. var local = new BMap.LocalSearch(map, {
  29. renderOptions: {
  30. map: map,
  31. autoViewport: true,
  32. selectFirstResult: false
  33. }
  34. });
  35. local.search(address);
  36. }
  37. </script>
  38. </head>
  39. <body onload="initialize();">
  40. <div id="map_canvas" style="width:100%; height:100%"></div>
  41. </body>
  42. </html>