openlayers加载bing地图
注:需要bingmap网站提供的许可key,注册微软账号就有了,https://www.bingmapsportal.com/Application#
new ol.source.BingMaps(options)api说明
Name |
Type |
Description |
options |
Bing Maps options.
Name |
Type |
Description |
cacheSize |
number | undefined |
Cache size. Default is 2048 . |
hidpi |
boolean | undefined |
If true hidpi tiles will be requested. Default is false . |
culture |
string | undefined |
Culture code. Default is en-us . |
key |
string |
Bing Maps API key. Get yours at http://www.bingmapsportal.com/. Required. |
imagerySet |
string |
Type of imagery. Required. |
maxZoom |
number | undefined |
Max zoom. Default is what’s advertized by the BingMaps service (21 currently). |
reprojectionErrorThreshold |
number | undefined |
Maximum allowed reprojection error (in pixels). Default is 0.5 . Higher values can increase reprojection performance, but decrease precision. |
tileLoadFunction |
ol.TileLoadFunctionType | undefined |
Optional function to load a tile given a URL. The default is
function(imageTile, src) {
imageTile.getImage().src = src;
};
|
wrapX |
boolean | undefined |
Whether to wrap the world horizontally. Default is true . |
transition |
number | undefined |
Duration of the opacity transition for rendering. To disable the opacity transition, pass transition: 0 . |
|
var styles = [//图层样式
'Road',
'RoadOnDemand',
'Aerial',
'AerialWithLabels',
'collinsBart',
'ordnanceSurvey'
];
//初始化bing地图
var bingMapLayer=new ol.layer.Tile({
visible: false,
preload: Infinity,
source: new ol.source.BingMaps({
key: 'bingmap key',
imagerySet: 'Road'//图层样式。
}) }));
//初始化地图
var map = new ol.Map({
layers: bingMapLayer,
// Improve user experience by loading tiles while dragging/zooming. Will make
// zooming choppy on mobile or slow devices.
loadTilesWhileInteracting: true,
target: 'map',
view: new ol.View({
center: [-6655.5402445057125, 6709968.258934638],
zoom: 13
})
});