zoukankan      html  css  js  c++  java
  • 腾讯地图,拖拽标注,获取坐标

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>腾讯地图,拖拽标注获取坐标</title>
    <style type="text/css">
    *{
        margin:0px;
        padding:0px;
    }
    body, button, input, select, textarea {
        font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
    }
    p{
        width:603px;
        padding-top:3px;
        overflow:hidden;
    }
    #container {
       width:603px;
       height:767px;
    }
    #mapcon {
       width:603px;
       height:767px;
    }
    </style>
    <script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp"></script>
    <script>
    var init = function() {
        var map = new qq.maps.Map(document.getElementById("container"),{
            center: new qq.maps.LatLng(39.916527,116.397128),
            zoom: 13
        });
        //绑定单击事件添加参数
        qq.maps.event.addListener(map, 'click', function(event) {
            alert('您点击的位置为: [' + event.latLng.getLat() + ', ' +
            event.latLng.getLng() + ']');
        });
        var anchor = new qq.maps.Point(6, 6),
            size = new qq.maps.Size(24, 24),
            origin = new qq.maps.Point(0, 0),
            icon = new qq.maps.MarkerImage('http://lbs.qq.com/javascript_v2/img/center.gif', size, origin, anchor);
        var marker = new qq.maps.Marker({
            icon: icon,
            map: map,
            Draggable:true,
            position:map.getCenter()});
        qq.maps.event.addListener(marker, 'dragend', function() {
                    var weizhi = marker.getPosition();
                    map.setCenter(weizhi);
                    console.log(weizhi.lat);
                    console.log(weizhi.lng);
                });    
    }
    </script>
    </head>
    <body onload="init()">
    <div id="container"></div>
    
    <p>给地图绑定了点击事件,当点击地图时,会弹出点击点的坐标。</p>
    </body>
    </html>
  • 相关阅读:
    linux常用命令的英文单词缩写
    Servlet Struts2 SpringMVC 获取参数与导出数据 方法比较
    Spring 整合Mybatis Mapper动态代理方法
    Spring 整合Mybatis dao原始方法
    Mybatis Mapper动态代理方式 typeAliases 别名的使用
    MySQL 高性能优化实战总结
    Chrome 浏览器最牛插件之一 Vimium
    Spring Cloud-微服务架构集大成者
    单点登录原理与简单实现
    Spring-WebSocket 教程
  • 原文地址:https://www.cnblogs.com/zonglonglong/p/7767502.html
Copyright © 2011-2022 走看看