百度地图Api进阶教程-点击生成和拖动标注4.html

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>12.1</title>
    <script type="text/javascript">
        var iscreatr = false;
        function initialize() {
            var map = new BMap.Map("container", { minZoom: 12, maxZoom: 25 });
            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 lable = new BMap.Label("我是可以拖拽的", { offset: new BMap.Size(20, -10) });
                marker.setLabel(lable);
                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 style="float: left; width: 100px;">
        1</div>
    <div id="container" style="width: 800px; height: 500px">
    </div>
    <div id="r-result" style="float: left; width: 100px;">
        打印坐标</div>
    <div id="result">
    </div>
</body>
</html>
时间: 2024-12-24 12:22:44

百度地图Api进阶教程-点击生成和拖动标注4.html的相关文章

百度地图Api进阶教程-实例高级操作8.html

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>16.1</title> <script type=text/javascript src=http://fw.qq.com/ipaddress></script&g

百度地图Api进阶教程-基础地图示例1.html

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>百度地图</title> <script type="text/javascript"> function initialize() { var map

百度地图Api进阶教程-创建标注和自定义标注3.html

<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>1

百度地图Api进阶教程-默认控件和自定义控件2.html

<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>1

百度地图Api进阶教程-弹出信息窗口5.html

<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>1

百度地图Api进阶教程-点聚合9.html

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;

百度地图Api进阶教程-用户自定义数据(标记和搜索)7.html

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body, html,#allmap {width: 100%;height: 100%;overflow: hidden;} #l-map{

百度地图API快速调用,一键生成百度地图

对于在网站或者网页之内插入百度地图插件,可能很多编程技术人员都知道如何来做,但是做起来所花费的时间都比较长,那么下面跟大家分享一下如何快速调用百度地图API,一件生成百度地图的方法,这种方法适用于任何的编程语言,所以有兴趣的编程开发者可以保存一下.body之间源代码如下:<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true&quo

百度地图api,使用QT同时绘制多个标注

myMap.html     文件内容: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type=