Openlayers3 加载百度地图,天地图
生活随笔
收集整理的這篇文章主要介紹了
Openlayers3 加载百度地图,天地图
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
openlayers3 加載百度地圖:
var projection = ol.proj.get("EPSG:3857");var resolutions = [];for(var i=0; i<19; i++){resolutions[i] = Math.pow(2, 18-i);}var tilegrid = new ol.tilegrid.TileGrid({origin: [0,0],resolutions: resolutions});var baidu_source = new ol.source.TileImage({projection: projection,tileGrid: tilegrid,tileUrlFunction: function(tileCoord, pixelRatio, proj){if(!tileCoord){return "";}var z = tileCoord[0];var x = tileCoord[1];var y = tileCoord[2];if(x<0){x = "M"+(-x);}if(y<0){y = "M"+(-y);}return "http://online3.map.bdimg.com/onlinelabel/?qt=tile&x="+x+"&y="+y+"&z="+z+"&styles=pl&udt=20151021&scaler=1&p=1";}});var baidu_layer = new ol.layer.Tile({source: baidu_source});var map = new ol.Map({target: 'map',layers: [baidu_layer],view: new ol.View({center: [12959773,4853101],zoom: 12})});openlayers3 加載天地圖:
路網 var tian_di_tu_road_layer = new ol.layer.Tile({title: "天地圖路網",source: new ol.source.XYZ({url: "http://t4.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}"}) }); map.addLayer(tian_di_tu_road_layer); 注記 var tian_di_tu_annotation = new ol.layer.Tile({title: "天地圖文字標注",source: new ol.source.XYZ({url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}'}) }); map.addLayer(tian_di_tu_annotation); 衛星影像 var tian_di_tu_satellite_layer = new ol.layer.Tile({title: "天地圖衛星影像",source: new ol.source.XYZ({url: 'http://t3.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}'}) }); map.addLayer(tian_di_tu_satellite_layer);?
轉載于:https://my.oschina.net/u/1783074/blog/714449
總結
以上是生活随笔為你收集整理的Openlayers3 加载百度地图,天地图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WCF学习之旅—基于Fault Cont
- 下一篇: PHP 获取当前类名、方法名、URL地址