Here Maps - 在 "choose view" 菜单中切换图块图层
Here Maps - toggle tile layer in "choose view" menu
我可以使用此代码创建一个图块图层并将其添加到地图中...
var tileProvider = new H.map.provider.ImageTileProvider({
opacity: 0.8,
getURL: function (column, row, zoom) {
return 'https://1.base.maps.api.here.com/maptile/2.1/truckonlytile/newest/reduced.day/' + zoom + '/' + column + '/' + row + '/256/png8?app_id=...&app_code=...'
}
});
overlayLayer = new H.map.layer.TileLayer(tileProvider, {
// Let's make it semi-transparent
opacity: 0.8
});
map.addLayer(overlayLayer);
这很好用,图层覆盖在地图上,但我希望能够通过 "Choose View" 菜单切换它 on/off。
我不知道该怎么做...我试过了...
var defaultLayers = platform.createDefaultLayers();
ui.removeControl('mapsettings');
var ms = new H.ui.MapSettingsControl( {
baseLayers : [ {
label: 'Map View',layer: defaultLayers.raster.normal.map
},{
label: 'Satellite',layer: defaultLayers.raster.satellite.map
}, {
label: 'Terrain',layer: defaultLayers.raster.terrain.map
},{
label: 'overlay', layer: overlayLayer
}
],
layers: [{
label: 'layer.traffic', layer: defaultLayers.vector.normal.traffic
},
{
label: 'layer.incidents', layer: defaultLayers.vector.normal.trafficincidents
}
]
});
ui.addControl('customized',ms);
...但它不起作用。
有没有办法通过菜单像这样切换以后制作磁贴?
您的图层应从 baseLayers 数组移动到 layers 数组:
var defaultLayers = platform.createDefaultLayers();
ui.removeControl('mapsettings');
var ms = new H.ui.MapSettingsControl({
baseLayers: [{
label: 'Map View', layer: defaultLayers.raster.normal.map
}, {
label: 'Satellite', layer: defaultLayers.raster.satellite.map
}, {
label: 'Terrain', layer: defaultLayers.raster.terrain.map
}],
layers: [{
label: 'layer.traffic', layer: defaultLayers.vector.normal.traffic
},
{
label: 'layer.incidents', layer: defaultLayers.vector.normal.trafficincidents
},
{
label: 'overlay', layer: overlayLayer
}]
});
ui.addControl('customized', ms);
我可以使用此代码创建一个图块图层并将其添加到地图中...
var tileProvider = new H.map.provider.ImageTileProvider({
opacity: 0.8,
getURL: function (column, row, zoom) {
return 'https://1.base.maps.api.here.com/maptile/2.1/truckonlytile/newest/reduced.day/' + zoom + '/' + column + '/' + row + '/256/png8?app_id=...&app_code=...'
}
});
overlayLayer = new H.map.layer.TileLayer(tileProvider, {
// Let's make it semi-transparent
opacity: 0.8
});
map.addLayer(overlayLayer);
这很好用,图层覆盖在地图上,但我希望能够通过 "Choose View" 菜单切换它 on/off。
我不知道该怎么做...我试过了...
var defaultLayers = platform.createDefaultLayers();
ui.removeControl('mapsettings');
var ms = new H.ui.MapSettingsControl( {
baseLayers : [ {
label: 'Map View',layer: defaultLayers.raster.normal.map
},{
label: 'Satellite',layer: defaultLayers.raster.satellite.map
}, {
label: 'Terrain',layer: defaultLayers.raster.terrain.map
},{
label: 'overlay', layer: overlayLayer
}
],
layers: [{
label: 'layer.traffic', layer: defaultLayers.vector.normal.traffic
},
{
label: 'layer.incidents', layer: defaultLayers.vector.normal.trafficincidents
}
]
});
ui.addControl('customized',ms);
...但它不起作用。
有没有办法通过菜单像这样切换以后制作磁贴?
您的图层应从 baseLayers 数组移动到 layers 数组:
var defaultLayers = platform.createDefaultLayers();
ui.removeControl('mapsettings');
var ms = new H.ui.MapSettingsControl({
baseLayers: [{
label: 'Map View', layer: defaultLayers.raster.normal.map
}, {
label: 'Satellite', layer: defaultLayers.raster.satellite.map
}, {
label: 'Terrain', layer: defaultLayers.raster.terrain.map
}],
layers: [{
label: 'layer.traffic', layer: defaultLayers.vector.normal.traffic
},
{
label: 'layer.incidents', layer: defaultLayers.vector.normal.trafficincidents
},
{
label: 'overlay', layer: overlayLayer
}]
});
ui.addControl('customized', ms);