Showing GeoJSON data on overlay

房东的猫 提交于 2019-12-08 03:29:43

问题


I'm trying to show/hide some GeoJSON data on an overlay layer. I've the data as an object, but not at some server.

If I use the overlay type 'geoJSON', I'm getting a Eror:

A base layer must have an url

How do I show/hide my data using the overlay show/hide?

The mixed-layers-overlays-geojson-example is not working for me because it uses remote (xyz-json) data.

Additional information: I've the data in some object that I'm intending to modify/update based on user interaction.

PS: it's probably very simple problem

Edit: I made a plunker of the situation. It shows the dynamic adding and removing of a path object and some empty functions for the geoJSON objects.


回答1:


I (my collegue) found some ugly answer: accessing the leaflet layers directly.

I forked the plunker from the description and added some functions. See my functions transformGeoObjToPath and geoToLeafletLayer. In our application we use layers of type 'featureGroup' for additional stuff like selecting, but this is not in the 'solution' example

But the solution is not 'beautiful', because it accesses the leaflet directly.



来源:https://stackoverflow.com/questions/32628893/showing-geojson-data-on-overlay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!