Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Complete Example of VectorLayer and TopoJson #101

Open
sirilicious opened this issue Dec 15, 2017 · 0 comments
Open

Complete Example of VectorLayer and TopoJson #101

sirilicious opened this issue Dec 15, 2017 · 0 comments

Comments

@sirilicious
Copy link

sirilicious commented Dec 15, 2017

#Hi! I'm not able to render a VectorLayer from mapzen, which is provided as TopoJson.

I noticed that the URL is not getting resolved with z,x and y, as my browser is complaining:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) https://tile.mapzen.com/mapzen/vector/v1/512/all/%7Bz%7D/%7Bx%7D/%7By%7D.topojson?api_key=***

How can I specify an OLVectorSource with XYZ?

OLVectorSourceOptions optionsMapzen = new OLVectorSourceOptions();
optionsMapzen.setUrl("https://tile.mapzen.com/mapzen/vector/v1/512/all/{z}/{x}/{y}.topojson?api_key=" + apiKey);
optionsMapzen.setInputProjection(Projections.EPSG4326);
OLFeatureFormat format = OLFeatureFormat.TOPOJSON;
optionsMapzen.setFormat(format);
OLTopoJSONFormatOptions formatOptions = new OLTopoJSONFormatOptions();
formatOptions.setDefaultDataProjection(Projections.EPSG4326);
try {
   optionsMapzen.setFormatOptions(formatOptions);
} catch (JsonProcessingException e) {
...
}

OLVectorSource sourceMapZen = new OLVectorSource(optionsMapzen);
OLVectorLayer layerMapzen = new OLVectorLayer(sourceMapZen);

OLStyle style = StyleUtils.createDefaultStyle();
layerMapzen.setStyle(style);

map.addLayer(layerMapzen);

Furthermore, according to this tutorial I am missing the part where to specify the layers:

"{layerName:'layer',layers:['water','roads','buildings']}"

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant