maps.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>服务端IP普通定位</title>
  7. <style type="text/css">
  8. html{height:100%}
  9. body{height:100%;margin:0px;padding:0px}
  10. #container{height:100%}
  11. </style>
  12. <script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=tF8XaCqUG9ZjFR66lqqNXmLzeT24gtGF">
  13. </script>
  14. </head>
  15. <body>
  16. <div id="container"></div>
  17. <script type="text/javascript">
  18. var map = new BMap.Map("container");
  19. // 创建地图实例
  20. {% if bdgps %}
  21. var point = new BMap.Point({{ bdgps[0] }} ,{{ bdgps[1] }});
  22. {% else %}
  23. var point = new BMap.Point(116.404, 39.915);
  24. {% endif %}
  25. // 创建点坐标
  26. map.centerAndZoom(point, 15);
  27. // 初始化地图,设置中心点坐标和地图级别
  28. map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
  29. map.addControl(new BMap.NavigationControl());
  30. map.addControl(new BMap.ScaleControl());
  31. map.addControl(new BMap.OverviewMapControl());
  32. map.addControl(new BMap.MapTypeControl());
  33. map.addOverlay(new BMap.Marker(point));
  34. </script>
  35. {{ bdgps[3] }}
  36. </body>
  37. </html>