I am working on a map renderer in JavaScript, and I need to render vector tiles. For this task, I need to know, for example, which kind of transportation layer (road) I am rendering. Is it a highway, a pedestrian path, or a rail? This is necessary to correctly distinguish which ones to render and which not to render and how to render.
I am serving the map with OpenMapTiles, using nothing more than ./quickstart.sh and make start-postserve.
With JavaScript, I receive the PBF data and convert it into an appropriate format that gives me a layer containing several pieces of information about it. However, I cannot understand how to correctly interpret the keys/values information about the layer, particularly for the transportation layer.
Here is what I've done:
if (layer.name === "transportation") {
let index = layer.keys.indexOf("class");
if (layer.values[index].stringValue === 'transit') {
geometry = this.parseGeometry(feature.geometry);
this.renderLine(geometry, scale);
}
}
These are the details about the layer that I receive:
They seem nonsensical and somewhat redundant to me, and I am unable to use those data. I was assuming that the keys array references each index in the values array, but that appears to be false. For example, if I want to know if the transportation class is rail, I should check the index 0 of the values, but that doesn't seem to be related. I would appreciate any hints on this matter.
@lorenzoMezza Which keys and values from the layer are relevant to each feature are spelled out in the tags field of the feature, which alternates key references and value references.
I am working on a map renderer in JavaScript, and I need to render vector tiles. For this task, I need to know, for example, which kind of transportation layer (road) I am rendering. Is it a highway, a pedestrian path, or a rail? This is necessary to correctly distinguish which ones to render and which not to render and how to render.
I am serving the map with OpenMapTiles, using nothing more than ./quickstart.sh and make start-postserve.
With JavaScript, I receive the PBF data and convert it into an appropriate format that gives me a layer containing several pieces of information about it. However, I cannot understand how to correctly interpret the keys/values information about the layer, particularly for the transportation layer.
Here is what I've done:
These are the details about the layer that I receive:
They seem nonsensical and somewhat redundant to me, and I am unable to use those data. I was assuming that the keys array references each index in the values array, but that appears to be false. For example, if I want to know if the transportation class is rail, I should check the index 0 of the values, but that doesn't seem to be related. I would appreciate any hints on this matter.