ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
682 stars 228 forks source link

Missing "id" property in GeoJSON feature breaks the rendering #302

Closed benjaminh closed 4 years ago

benjaminh commented 4 years ago

Following the documentation related to using vl-layer-vector.

It looks like <vl-source-vector :features.sync="features"></vl-source-vector> is looking at some point for an id property in the feature GeoJSON definition. If missing, features aren't rendered without error message in console.

I'm loading data from an API so contrary to the doc, I don't manually define my features and they don't have an id property.

Maybe I missed something but I didn't find it was part of the GeoJSON specification. So is this a vuelayers bug ? Could id, if necessary for the lib, be defined in the template rather than in the input data ? Or maybe throw a warning or exception ?

If you want to reproduce the issue, just follow the doc example and remove the id: fakerator.misc.uuid(), in the features declaration.

ghettovoice commented 4 years ago

Hello @benjaminh , which version of vuelayers do you use? There was some time ago such problem with features ids, but it's already resolved. Here is the demo with latest version, as you can see nothing abnormal even without ids https://jsfiddle.net/ghettovoice/dsbh04pm/. Also I don't see any problems on this page https://vuelayers.github.io/#/docs/component/vector-layer, features still loaded and rendered.

As you correctly mention id is not required by spec and VueLayers too. VueLayers appends uuid ids for all loaded features without id automatically.

benjaminh commented 4 years ago

Hello @ghettovoice ! According to my package.json, the vuelayers dependency is ^0.11.22.

ghettovoice commented 4 years ago

I guess the problem somewhere in another place. Maybe map view projection don't match the projection of features, so they are rendered in not expected place. Can you make re-produce demo? Or dump your code here

goof03 commented 4 years ago

Hi @ghettovoice, i confirm i have a vector layer with factory function like this : <vl-style-func :factory="styleFuncFactory" />

Dynamic style on feature property value and without id vlayer features disappear definitely … This bug make my day :D

Only since version 11.22

ghettovoice commented 4 years ago

Hi @goof03 , thanks for response! This issue more clear now, I successfully reproduce it and now see a problem. Thanks!

ghettovoice commented 4 years ago

Here is updated demo with new v0.11.24 https://jsfiddle.net/ghettovoice/dsbh04pm/