百度地图Api进阶教程-点击生成和拖动标注4.html
来源:互联网 发布:淘宝买家退款率怎么查 编辑:程序博客网 时间:2024/05/29 00:29
转载:http://blog.csdn.net/sd0902/article/details/8471324
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>百度地图</title>
- <script type="text/javascript">
- var iscreatr=false;
- function initialize() {
- //---------------------------------------------基础示例---------------------------------------------
- var map = new BMap.Map("allmap",{minZoom:12,maxZoom:20}); // 创建Map实例
- //map.centerAndZoom(new BMap.Point(116.4035,39.915),15); //初始化时,即可设置中心点和地图缩放级别。
- map.centerAndZoom("成都",13); // 初始化地图,设置中心点坐标和地图级别。
- map.enableScrollWheelZoom(true);//鼠标滑动轮子可以滚动
- map.addEventListener("click", function(e){
- if(iscreatr==true)return;
- //---------------------------------------------遮盖物---------------------------------------------
- iscreatr=true;
- var point = new BMap.Point(e.point.lng ,e.point.lat);//默认
- // 创建标注对象并添加到地图
- var marker = new BMap.Marker(point);
- var label = new BMap.Label("我是可以拖动的",{offset:new BMap.Size(20,-10)});
- marker.setLabel(label)
- map.addOverlay(marker);
- marker.enableDragging(); //可拖拽
- marker.addEventListener("dragend", function(e){
- document.getElementById("r-result").innerHTML = e.point.lng + ", " + e.point.lat;//打印拖动结束坐标
- });
- });
- }
- function loadScript() {
- var script = document.createElement("script");
- script.src = "http://api.map.baidu.com/api?v=1.4&callback=initialize";
- document.body.appendChild(script);
- }
- window.onload = loadScript;
- </script>
- </head>
- <body>
- <div id="r-result" style="float:left;width:100px;">打印坐标</div>
- <div id="allmap" style="width: 800px; height: 500px"></div>
- </body>
- </html>
- <script type="text/javascript">
- // 移动到某点 map.panTo(new BMap.Point(116.409, 39.918));
- // map.setZoom(14); //放到到14级
- </script>
- 百度地图Api进阶教程-点击生成和拖动标注4.html
- 百度地图Api进阶教程-点击生成和拖动标注4.html
- 百度地图Api进阶教程-创建标注和自定义标注3.html
- 百度地图Api进阶教程-创建标注和自定义标注3.html
- 百度地图Api进阶教程-基础地图示例1.html
- 百度地图Api进阶教程-基础地图示例1.html
- 百度地图Api进阶教程-地图鼠标左右键操作实例和鼠标样式6.html
- 百度地图Api进阶教程-地图鼠标左右键操作实例和鼠标样式6.html
- 百度地图API中使用ajax实现点击地图生成标注并保存到数据库
- 百度地图Api进阶教程-弹出信息窗口5.html
- 百度地图Api进阶教程-实例高级操作8.html
- 百度地图Api进阶教程-点聚合9.html
- 百度地图Api进阶教程-弹出信息窗口5.html
- 百度地图Api进阶教程-实例高级操作8.html
- 百度地图Api进阶教程-点聚合9.html
- 百度地图Api进阶教程-默认控件和自定义控件2.html
- 百度地图Api进阶教程-用户自定义数据(标记和搜索)7.html
- 百度地图Api进阶教程-默认控件和自定义控件2.html
- OSG开发
- 百度地图Api进阶教程-默认控件和自定义控件2.html
- 《高效能程序员的修炼》勘误表(2013.11.16更新)
- 百度地图Api进阶教程-创建标注和自定义标注3.html
- Dojo EnhancedGrid新功能评介(1)——Pagination
- 百度地图Api进阶教程-点击生成和拖动标注4.html
- LoadRunner压力测试实例
- HDU 4678 Mine
- LibSVM分类的实用指南
- 串口中断接收方式详细比较
- QT5 中使用QPrinter
- 百度地图Api进阶教程-弹出信息窗口5.html
- 统计语言模型学习笔记
- Android---构建一个OpenGL ES环境