OpenLayers3 고덕 맵 로드

1317 단어 OpenLayers
AMapSource.js
ol.source.AMap = function(options){
    var options = options ? options : {};

    var attributions;
    if(options.attributions !== undefined){
        attributions = option.attributions;
    }else{
        attributions = [ol.source.AMap.ATTRIBUTION];
    }

    var url;
    if(options.mapType == "sat"){
        url ="http://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}";
    }else{
        url = "http://webrd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}";
    }

    ol.source.XYZ.call(this, {
        crossOrigin: 'anonymous',   // 
        cacheSize: options.cacheSize,
        projection: ol.proj.get('EPSG:3857'),
        // urls:urls,
        url:url,
        wrapX: options.wrapX !== undefined ? options.wrapX : true

    });

}

ol.inherits(ol.source.AMap,ol.source.XYZ);

ol.source.AMap.ATTRIBUTION = new ol.Attribution({
    html: '© ' +
'고덕 지도''
});

호출:
var aMapSat = new ol.layer.Tile({
    title: " ",
    source: new ol.source.AMap({mapType:"sat"})
});
map.addLayer(aMapSat);

실현 효과:

좋은 웹페이지 즐겨찾기