zoukankan      html  css  js  c++  java
  • Leaflet获取可视范围内4个顶点

    //地图级别改变时发生
    map.on("zoomend", function (e) {
    var zoom_val = e.target.getZoom();
    map_drag();;
    });
    //拖动地图时发生
    map.on("moveend", function (e) {
    map_drag();;
    });

    function map_drag() {
    //左下角坐标(西南方)
    var leftdown = map.getBounds().getSouthWest().lng + "," + map.getBounds().getSouthWest().lat;
    L.circleMarker([map.getBounds().getSouthWest().lat, map.getBounds().getSouthWest().lng], { fillColor: "#f00", radius: 10 }).bindLabel("左下角坐标" + leftdown, { direction: 'right', noHide: true }).addTo(map);
    //右上角坐标(东北方向)
    var rightdown = map.getBounds().getNorthEast().lng + "," + map.getBounds().getNorthEast().lat;
    L.circleMarker([map.getBounds().getNorthEast().lat, map.getBounds().getNorthEast().lng], { fillColor: "#f00", radius: 10 }).bindLabel("右上角坐标" + rightdown, { direction: 'left', noHide: true }).addTo(map);
    //var strText = "当前地图级别:" + zoom_val + " 左下角坐标:" + leftdown + " 右下角坐标:" + rightdown;
    //左上角:西北方
    var leftdown = map.getBounds().getNorthWest().lng + "," + map.getBounds().getNorthWest().lat;
    L.circleMarker([map.getBounds().getNorthWest().lat, map.getBounds().getNorthWest().lng], { fillColor: "#f00", radius: 10 }).bindLabel("左上角坐标" + leftdown, { direction: 'right', noHide: true }).addTo(map);

    //右下角:东南方
    var leftdown = map.getBounds().getSouthEast().lng + "," + map.getBounds().getSouthEast().lat;
    L.circleMarker([map.getBounds().getSouthEast().lat, map.getBounds().getSouthEast().lng], { fillColor: "#f00", radius: 10 }).bindLabel("右下角坐标" + leftdown, { direction: 'left', noHide: true }).addTo(map);

    }

  • 相关阅读:
    cocos2d-x CCNotificationCenter一个优化想法
    【备忘】尾调用(尾递归)--来自维基百科
    [转] 关于Mongodb的全面总结,学习mongodb的人,可以从这里开始
    [转]编程修养
    DirectX11 SDK 例程报错解决方法
    unity3d Vector3.Lerp解析
    unity3d 三分钟实现简单的赛车漂移
    Unity 5.3.1 No Android/IOS module loaded
    unity3d 音频无缝循环
    unity3d 扩展NGUI Tweener —— TweenTime
  • 原文地址:https://www.cnblogs.com/huangzhen22/p/10509520.html
Copyright © 2011-2022 走看看