百度地图API实现地图定位

1、引用JS:

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=87be68605271c5e4cfe712787041be0a"></script>

2、HTML:

东经:
input name="longitude" onkeyup="dingwei()"  value="@row["longitude"].ToString()" type="text"/>
span class="valid nullable" rule="number" msg="请填写数字"span>
北纬:
="latitude"  onkeyuplatitude"].ToString()" type>

3、JS代码

<script type="text/javascript">
    var map;
    var level = 17;
     marker;

    $(function () {
        //地图定位
        map = new BMap.Map("map");
        var top_right_navigation = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_RIGHT,type: BMAP_NAVIGATION_CONTROL_SMALL }); 右上角,仅包含平移和缩放按钮
        map.addControl(top_right_navigation);
        map.addEventListener("zoomend", () {
            level = map.getZoom();
        });
        var point = new BMap.Point(117.218,31.861);
        map.centerandZoom(point,level);
        marker = new BMap.Marker(point,{ enableDragging: true });
        marker.addEventListener("dragging",1)"> (evt) {
            $("input[name='longitude']").val(evt.point.lng)
            $("input[name='latitude']").val(evt.point.lat)
        });
        map.addOverlay(marker);
        dingwei();
    });

    地图定位
     dingwei() {
        if (Simpovalidate.valid()) { 验证输入
            var inputlongitude = $("input[name='longitude']");
            var inputlatitude = $("input[name='latitude']"if ($.trim(inputlongitude.val()) != ""
                && $.trim(inputlatitude.val()) != "") {
                var longitude = parseFloat(inputlongitude.val());
                var latitude = parseFloat(inputlatitude.val());
                new BMap.Point(longitude,latitude);
                map.centerandZoom(point,level);
                marker.setPosition(point);
            }
        }
    }
</script>
View Code

 

相关文章

https://www.osgeo.cn/qgis-tutorial/overview.html https:...
设计方案是工程建设最关键的环节,也是影响城市规划的基本因...
BIM与GIS的区别与联系http://www.bimcn.org/cjwt/2018111516...
成功有感之给年轻人的10个忠告1、努力工作要努力,随随便便过...
鉴于陆地多边形为ShapelyMultiPolygon,我想找到代表例如多边...
背景与宣言传统的GISC/S开发已经很被别人不屑了,在时代的洪...