maptalks.js icon indicating copy to clipboard operation
maptalks.js copied to clipboard

Conditional Symbol markerFile

Open jokroese opened this issue 3 years ago • 3 comments

maptalks's version and what browser you use?

Maptalks version: 1.0.0-rc.14 Browser: Firefox, 106.0.5

Issue description

I have a geojson file with several features in. I want to use different symbols for representing each of the features, conditional on values of the feature (such as latitude, longitude and other properties).

I would expect to be able to use a standard if, else function to assign a symbol to each feature (as shown in the reproduction URL).

However, doing this leads the symbols to overlap on each other. Specifically:

  • the first feature in the collection is shown with the correct symbol correctly
  • the second feature is shown with the correct symbol and the symbol of the first feature.
  • so on...

Please provide a reproduction URL (on any jsfiddle like site)

https://codepen.io/jokroese/pen/NWzwPeV

Note how the symbol for Berlin (the second feature of the collection) has both the (correct) Berlin symbol and the (incorrect) London symbol.

jokroese avatar Nov 17 '22 20:11 jokroese

I made a simple example, https://codepen.io/deyihu/pen/jOKaqJB?editors=0010 Because I don't fully understand your needs, I'm not sure if it's what you want @joekroese

deyihu avatar Nov 18 '22 02:11 deyihu

Hi @deyihu! I'll try to be clearer with what I'm trying to do :)

What I am trying to do is:

  • have the symbol of the eye be the only symbol for London (the western coordinates in the example) and
  • the tower be the only symbol for Berlin (the eastern coordinates in the example)

The problem is that, instead of just showing the tower in Berlin, it shows both the eye and the tower.

jokroese avatar Nov 18 '22 11:11 jokroese

In other words:

I have a single GeoJSON file with type FeatureCollection. How can I represent the features with multiple different symbols?

jokroese avatar Nov 28 '22 10:11 jokroese