百度瓦片地图URL和图片关系示例

2022-01-07 14:41:17 浏览数 (1)

代码语言:javascript复制
<script type="text/javascript">



// 百度地图API功能

var tileLayer = new BMap.TileLayer();

tileLayer.getTilesUrl = function(tileCoord, zoom) {

    var x = tileCoord.x;

    var y = tileCoord.y;

    var url = outputPath   zoom   '/'   x   '/'   y   '.png';   //根据当前坐标,选取合适的瓦片图

    return url;

}

var MyMap = new BMap.MapType('MyMap', tileLayer, {minZoom: 1, maxZoom: 4});

var map = new BMap.Map('allmap', {mapType: MyMap});

map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}));

map.centerAndZoom(new BMap.Point(0, 0), 3);

</script>

0 人点赞