欢迎访问我的博客

ditu

  1. var tian_di_tu_road_layer = new ol.layer.Tile({  
  2.     title: "天地图路网",  
  3.     source: new ol.source.XYZ({  
  4.         url: "http://t4.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}"  
  5.     })  
  6. });  
  7.   
  8. var tian_di_tu_annotation = new ol.layer.Tile({  
  9.     title: "天地图文字标注",  
  10.     source: new ol.source.XYZ({  
  11.         url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}'  
  12.     })  
  13. });  

2.离线天地图

 

[html] view plain copy
 
  1. var tiandituBaseLayer = new ol.layer.Tile({  
  2.     title:"天地图基础图层",  
  3.     source: new ol.source.XYZ({  
  4.         tileUrlFunction:function(tileCoord){  // 参数tileCoord为瓦片坐标  
  5.             var z = tileCoord[0];  
  6.             var x = tileCoord[1];  
  7.             var y = -tileCoord[2]-1;  
  8.             return 'http://localhost:8080/tiantai/TDTVec/L'+z+'/'+y+'/'+x+'.png'  
  9.         },  
  10.         projection:'EPSG:4326'  
  11.     })  
  12. });  
  13.   
  14. // 添加一个使用离线瓦片地图的层  
  15. var tiandituMarkLayer = new ol.layer.Tile({  
  16.     title:"天地图标注图层",  
  17.     source: new ol.source.XYZ({  
  18.         tileUrlFunction:function(tileCoord){  // 参数tileCoord为瓦片坐标,遍历整个坐标系统  
  19.             var z = tileCoord[0];  
  20.             var x = tileCoord[1];  
  21.             var y = -tileCoord[2]-1;//不是经纬度,是瓦片坐标  
  22.             return 'http://localhost:8080/tiantai/TDTVecAnno/L'+z+'/'+y+'/'+x+'.png';  
  23.         },  
  24.         projection:'EPSG:4326'  
  25.     })  
  26. });  

3.在线天地图影像

 

[javascript] view plain copy
 
  1. var tiandituSatelliteLayer = new ol.layer.Tile({  
  2.        source: new ol.source.XYZ({  
  3.            url:'http://t3.tianditu.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}'//天地图影像  
  4.        }),  
  5.        projection: 'EPSG:3857'  
  6.    })  
  7.      
  8. var tiandituSatelliteLabel = new ol.layer.Tile({  
  9.        source: new ol.source.XYZ({  
  10.            url:'http://t3.tianditu.cn/DataServer?T=cia_w&X={x}&Y={y}&L={z}'//天地图影像 标注  
  11.        }),  
  12.        projection: 'EPSG:3857'  
  13.    })  

4.在线高德地图

[javascript] view plain copy
 
  1. var gaodeMapLayer = new ol.layer.Tile({  
  2.         source: new ol.source.XYZ({  
  3.             url:'http://webrd03.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8'//高德地图在线  
  4.         }),  
  5.         projection: 'EPSG:3857'  
  6.     })  

 

5.3857坐标系下的arcgis切片

 

 

[html] view plain copy
 
  1. var tileLayer = new ol.layer.Tile({  
  2.     source: new ol.source.XYZ ({  
  3.         tileUrlFunction: function(tileCoord) {  
  4.             var x = 'C'+zeroPad(tileCoord[1],8,16);  
  5.             var y = 'R'+zeroPad(-tileCoord[2]-1,8,16);  
  6.             var z = 'L'+zeroPad(tileCoord[0],2,10);  
  7.             return 'tiles/wt/'+z+'/'+y+'/'+x+'.png';  
  8.         },  
  9.         projection: 'EPSG:3857'  
  10.     })  
  11. });   
[html] view plain copy
 
  1.      function zeroPad(num,len,radix){  
  2.     var str = num.toString(radix || 10);  
  3.     while(str.length<len){  
  4.         str = "0"+ str;  
  5.     }  
  6.     return str;  
  7. }  

 

 

6.Open Street Map 地图层

默认:

 

[html] view plain copy
 
  1. var openStreetMapLayer = new ol.layer.Tile({  
  2.      source: new ol.source.OSM()  
  3.  });  

地形:

 

[javascript] view plain copy
 
  1. var osmTerrainlayer = new ol.layer.Tile({  
  2.         source : new ol.source.OSM(  
  3.                 url:'http://tile-{a-c}.openstreetmap.fr/hot/{z}/{x}/{y}.png'//osm地形  
  4.         )  
  5. })  

自行车地图:

 

[javascript] view plain copy
 
  1. var osmBicycleLayer = new ol.layer.Tile({  
  2.         source: new ol.source.OSM({   
  3.             url:'http://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png'//osm自行车地图  
  4.         })   
  5.     })   

 


7.在线Bing地图

[html] view plain copy
 
  1. var bingMapLayer = new ol.layer.Tile({  
  2.         source: new ol.source.BingMaps({  
  3.             key: 'AkjzA7OhS4MIBjutL21bkAop7dc41HSE0CNTR5c6HJy8JKc7U9U9RveWJrylD3XJ',  
  4.       imagerySet: 'Road'  
  5.         })  
  6.     });  

8.在线Stamen地图

 

 

[html] view plain copy
 
  1. var stamenLayer = new ol.layer.Tile({  
  2.         source: new ol.source.Stamen({  
  3.             layer: 'watercolor'  
  4.         })  
  5.     });  


9.在线MapQuest地图

 

[html] view plain copy
 
  1. var mapQuestLayer = new ol.layer.Tile({  
  2.         source: new ol.source.MapQuest({  
  3.             layer: 'osm'  
  4.         })  
  5.     });  


10.加载geoserver的WMS服务

 

[javascript] view plain copy
 
  1. var TileWMSLayer = new ol.layer.Tile({  
  2.         source: new ol.source.TileWMS({  
  3.             url: "http://192.168.88.21:8081/geowebcach/service/wms",  
  4.             params: {'LAYERS': 'tiantai','FORMAT':'image/png','SRS':'EPSG:0'},  
  5.             tileGrid: new ol.tilegrid.TileGrid({  
  6.                 //resolution和conf.xml中保持一致  
  7.                 resolutions: [0.00068664344191344954,0.00034332053122622185,0.00017165907588260801,8.5829537941304004e-005,4.2913579240149092e-005,2.1455599889571629e-005,1.07266102142829e-005,5.3633051071414502e-006,2.6816525535707251e-006],  
  8.                 tileSize: [256, 256],  
  9.                 origin:[-400,400]  
  10.             })  
  11.         }),  
  12.         projection: 'EPSG:4326'  
  13.     })  


11.ArcGIS Server发布的服务

[javascript] view plain copy
 
  1. var arcgisTileLayer = new ol.layer.Tile({  
  2.         source: new ol.source.TileArcGISRest({  
  3.             url: 'http://localhost:8399/arcgis/rest/services/test/MapServer'  
  4.         })  
  5.     })  

 

好像3.17版本才支持,如果服务启用缓存,访问的就是arcgis缓存切片

12.在线谷歌地图

谷歌交通地图:

 

[javascript] view plain copy
 
  1. var googleMapLayer = new ol.layer.Tile({  
  2.         source: new ol.source.XYZ({  
  3.             url:'http://www.google.cn/maps/vt/pb=!1m4!1m3!1i{z}!2i{x}!3i{y}!2m3!1e0!2sm!3i345013117!3m8!2szh-CN!3scn!5e1105!12m4!1e68!2m2!1sset!2sRoadmap!4e0'  
  4.         })  
  5.     });  

谷歌地形地图:

 

[javascript] view plain copy
 
  1. var googleTerrainLayer = new ol.layer.Tile({  
  2.        source: new ol.source.XYZ({  
  3.            url:'http://mt3.google.cn/vt/lyrs=t@131,r@216000000&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=Gal'//谷歌地形地图  
  4.        }),  
  5.        projection: 'EPSG:3857'  
  6.    })  


谷歌卫星地图(混合):

[javascript] view plain copy
 
    1. var googleSatelliteLayer = new ol.layer.Tile({  
    2.         source: new ol.source.XYZ({  
    3.             url:'http://mt2.google.cn/vt/lyrs=y&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=G'//谷歌卫星地图 混合  
    4.         }),  
    5.         projection: 'EPSG:3857'  
    6.     })  
posted @ 2017-12-08 15:55  对雪书空武  阅读(1041)  评论(0)    收藏  举报
敬请关注下一期节目