弄在线 调用的url有弄过的吗
因为项目需要 弄成超图底图 把百度底图改成超图。
所以 找了两天。。。。
// 百度地图层
var projection = ol.proj.get("EPSG:3857");
var resolutions = [];
for(var i=0; i<19; i++){
resolutions[i] = Math.pow(2, 18-i);
}
var baiduMapLayer = new ol.layer.Tile({
source: new ol.source.TileImage({
crossOrigin: 'anonymous',
projection: projection,
tileGrid: new ol.tilegrid.TileGrid({
origin: [0,0],
resolutions: resolutions
}),
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 superMapTileLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
// url: "http://tah.openstreetmap.org/Tiles/tile/${z}/${x}/${y}.png"
})
});
GIS中调用
var map = new ol.Map({
controls: ol.control.defaults().extend([
new ol.control.ScaleLine({})
]),
layers : [superMapTileLayer],
overlays : [ popupOverlay ],
target : 'map',
view : new ol.View({
center : [106.251367,37.472274],
projection : 'EPSG:4326',
zoom : 8
})
});
唉弄不出来。。。。。。大神们求看看。解决现在 已经遇到坑了
大神们留步
晚上通过一系列的努力 ,完事。。。大家 有问题的话回吧,我这个解决了。
var superMapTileLayer = new ol.layer.Tile({
source:new ol.source.XYZ({
title: "超图底图",
url:"http://t0.supermapcloud.com/FileService/image?map=quanguo&type=web&x={x}&y={y}&z={z}"
})
});
url的地址是怎么设置成自己想要的地图模型
小白
this.currentLayer = new ol.layer.Tile({}) 是什么意思,
还有source: new ol.source.TileWMS({})
<template>
<div id="map" class="hello">
</div>
</template>
<script>
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import * as control from 'ol/control';
import { Logo, TileSuperMapRest } from '@supermap/iclient-ol';
export default {
name: 'HelloWorld',
data(){
return{
map:null
}
},
mounted(){
this.initIcingMap();
},
methods:{
initIcingMap() {
var url = "https://iserver.supermap.io/iserver/services/map-world/rest/maps/World";
var map = new Map({
target: 'map',
controls: control.defaults({ attributionOptions: { collapsed: false } }).extend([new Logo()]),
view: new View({
center: [106.86, 39.71],
// maxZoom: 18,
// minZoom: 2,
zoom: 5,
projection: 'EPSG:4326',
})
});
var layer = new TileLayer({
source: new TileSuperMapRest({
url: url,
wrapX: true
}),
projection: 'EPSG:4326'
});
map.addLayer(layer);
},
}
}
</script>
<style scoped>
.hello{
width: 100%;
height: 100vh;
}
</style>