HereMaps javascript API 在缩放级别 12 显示 minor_roads
HereMaps javascript API displaying minor_roads at zoom level 12
我想在缩放级别 12 显示 minor_roads(住宅)。
但是,默认情况下(矢量瓦片)数据源似乎不包括 12 处的次要道路。
我尝试为缩放级别 12 设置道路宽度,但它似乎不起作用
minor_road_width: [[6, 1px], [7, 1px], [8, 1px], [9, 1px], [11, 1px], [12, 1px], [13, 1px],[14, 1px], [15, 2px]]
您可以设置此属性,但它们不适用于次要道路,因为它们不会被 Vector Tile 检索 API https://developer.here.com/documentation/vector-tiles-api/dev_guide/index.html 因为次要道路仅在缩放级别 >= 13
您需要自己绘制这样的道路才能使用 ROAD_GEOM 图层来使用 Fleet Telematics API (FTA)。请参阅 https://jsfiddle.net/L5vsjtwd/
上的示例
/**
* Shows the postcode layer provided by Platform Data Extension REST API
* https://developer.here.com/platform-extensions/documentation/platform-data/topics/introduction.html
*
* @param {H.Map} map A HERE Map instance within the application
*/
function showPostcodes(map, bubble){
var service = platform.getPlatformDataService();
service.searchByBoundingBox(
["CARTO_LINE_DO3", "CARTO_LINE_DO2"],
["CARTO_ID","CARTO_ID"],
map.getViewModel().getLookAtData().bounds.getBoundingBox(),
function(arrD){
for(var i=0; i<arrD.length; i++){
//console.log(arrD[i].getCell("FEATURE_TYPE"), arrD[i].getCell("WKT").toString());
map.addObject(new H.map.Polyline(
arrD[i].getCell("WKT"), { style: { lineWidth: 4 }}
));
}
},
console.error
);
}
/**
* Boilerplate map initialization code starts below:
*/
//Step 1: initialize communication with the platform
// In your own code, replace variable window.apikey with your own apikey
var platform = new H.service.Platform({
apikey: window.apikey
});
var defaultLayers = platform.createDefaultLayers();
//Step 2: initialize a map - not specificing a location will give a whole world view.
var map = new H.Map(document.getElementById('map'),
defaultLayers.vector.normal.map, {
pixelRatio: window.devicePixelRatio || 1
});
// add a resize listener to make sure that the map occupies the whole container
window.addEventListener('resize', () => map.getViewPort().resize());
map.setCenter({lat:52.5159, lng:13.3777});
map.setZoom(9);
//Step 3: make the map interactive
// MapEvents enables the event system
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
// Create the default UI components
var ui = H.ui.UI.createDefault(map, defaultLayers);
// create info bubble that is used to display the postcode data
bubble = new H.ui.InfoBubble(map.getCenter(), {
content: ''
});
bubble.close();
ui.addBubble(bubble);
map.addEventListener("mapviewchangeend", function(){
showPostcodes(map, bubble);
});
// Now use the map as required...
//setTimeout(function(){showPostcodes(map, bubble);}, 2000);
在上面的例子中是类似的问题(没有显示 rails 对于某些缩放级别)但是使用 FTA(图层“CARTO_LINE_DO3”,“CARTO_LINE_DO2”)和 JS API 是可能的。
文档:
- https://demo.support.here.com/pde/layers?region=WEU&release=latest&url_root=pde.api.here.com
- https://demo.support.here.com/pde/layer?region=WEU&release=latest&url_root=pde.api.here.com&layer=ROAD_GEOM_FC5
- https://demo.support.here.com/pde/maps?url_root=pde.api.here.com
- https://developer.here.com/documentation/fleet-telematics/dev_guide/index.html
- https://developer.here.com/documentation/content-map-attributes/dev_guide/index.html
我想在缩放级别 12 显示 minor_roads(住宅)。 但是,默认情况下(矢量瓦片)数据源似乎不包括 12 处的次要道路。 我尝试为缩放级别 12 设置道路宽度,但它似乎不起作用
minor_road_width: [[6, 1px], [7, 1px], [8, 1px], [9, 1px], [11, 1px], [12, 1px], [13, 1px],[14, 1px], [15, 2px]]
您可以设置此属性,但它们不适用于次要道路,因为它们不会被 Vector Tile 检索 API https://developer.here.com/documentation/vector-tiles-api/dev_guide/index.html 因为次要道路仅在缩放级别 >= 13
您需要自己绘制这样的道路才能使用 ROAD_GEOM 图层来使用 Fleet Telematics API (FTA)。请参阅 https://jsfiddle.net/L5vsjtwd/
上的示例/**
* Shows the postcode layer provided by Platform Data Extension REST API
* https://developer.here.com/platform-extensions/documentation/platform-data/topics/introduction.html
*
* @param {H.Map} map A HERE Map instance within the application
*/
function showPostcodes(map, bubble){
var service = platform.getPlatformDataService();
service.searchByBoundingBox(
["CARTO_LINE_DO3", "CARTO_LINE_DO2"],
["CARTO_ID","CARTO_ID"],
map.getViewModel().getLookAtData().bounds.getBoundingBox(),
function(arrD){
for(var i=0; i<arrD.length; i++){
//console.log(arrD[i].getCell("FEATURE_TYPE"), arrD[i].getCell("WKT").toString());
map.addObject(new H.map.Polyline(
arrD[i].getCell("WKT"), { style: { lineWidth: 4 }}
));
}
},
console.error
);
}
/**
* Boilerplate map initialization code starts below:
*/
//Step 1: initialize communication with the platform
// In your own code, replace variable window.apikey with your own apikey
var platform = new H.service.Platform({
apikey: window.apikey
});
var defaultLayers = platform.createDefaultLayers();
//Step 2: initialize a map - not specificing a location will give a whole world view.
var map = new H.Map(document.getElementById('map'),
defaultLayers.vector.normal.map, {
pixelRatio: window.devicePixelRatio || 1
});
// add a resize listener to make sure that the map occupies the whole container
window.addEventListener('resize', () => map.getViewPort().resize());
map.setCenter({lat:52.5159, lng:13.3777});
map.setZoom(9);
//Step 3: make the map interactive
// MapEvents enables the event system
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
// Create the default UI components
var ui = H.ui.UI.createDefault(map, defaultLayers);
// create info bubble that is used to display the postcode data
bubble = new H.ui.InfoBubble(map.getCenter(), {
content: ''
});
bubble.close();
ui.addBubble(bubble);
map.addEventListener("mapviewchangeend", function(){
showPostcodes(map, bubble);
});
// Now use the map as required...
//setTimeout(function(){showPostcodes(map, bubble);}, 2000);
在上面的例子中是类似的问题(没有显示 rails 对于某些缩放级别)但是使用 FTA(图层“CARTO_LINE_DO3”,“CARTO_LINE_DO2”)和 JS API 是可能的。
文档:
- https://demo.support.here.com/pde/layers?region=WEU&release=latest&url_root=pde.api.here.com
- https://demo.support.here.com/pde/layer?region=WEU&release=latest&url_root=pde.api.here.com&layer=ROAD_GEOM_FC5
- https://demo.support.here.com/pde/maps?url_root=pde.api.here.com
- https://developer.here.com/documentation/fleet-telematics/dev_guide/index.html
- https://developer.here.com/documentation/content-map-attributes/dev_guide/index.html