Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Layers should be grouped to disappear together when overlapped #6025

Closed
divya1c opened this issue Jan 19, 2018 · 3 comments
Closed

Layers should be grouped to disappear together when overlapped #6025

divya1c opened this issue Jan 19, 2018 · 3 comments

Comments

@divya1c
Copy link

divya1c commented Jan 19, 2018

I am looking to implement a way to have a round icon with a label at the side (layer1) and a small colored circle on the top right of the icon to indicate some property(layer2). I do not want to allow overlap of each group of icons. I chose circles to icons for my layer 2 since the color changes with a property.

Here's my code:

  map.addLayer({
    'id': 'basic-criticalinfrastructure-icon',
    'type': 'symbol',
    'interactive': true,
    'source': 'toggle-layer-markers',
    'layout': {
      "icon-image": "{category}",
      "icon-size": 0.8,
      "text-field": "Hello",
      "text-anchor": "left",
      "text-size": 10
    },
    'paint': {
      "text-translate": [12, 0]
    }
  });  
  map.addLayer({
    'id': 'basic-criticalinfrastructure-circle',
    'type': 'circle',
    'source': 'toggle-layer-markers',
    'paint': {
      'circle-color': '#ff0000',
      'circle-opacity': 1.0,
      'circle-radius': 4,
      'circle-stroke-width': 1,
      'circle-stroke-color': '#FFFFFF',
      'circle-translate': [7, -7]
    }
  });

Expected Behavior

When overlapped, the icon, text and circle disappear together.

Actual Behavior

Icon and text disappear and circles don't.

Heres what i don't want:
screen shot 2018-01-19 at 8 59 01 am

@ansis
Copy link
Contributor

ansis commented Jan 19, 2018

The only way to currently do this is to "bake" the status circle and icon into one image. So if you have the icons hospital, school and grocery with the statuses red and green you'd need to create hospital-red, hospital-green, school-red, school-green, grocery-red, grocery-green icons. This is far from ideal of course.

#4366 has a proposal about creating symbol layers with multiple icons. I'll close this issue as a duplicate of that one. Please let us know if you have any ideas about how we should add this functionality!

@ansis ansis closed this as completed Jan 19, 2018
@ChrisLoer
Copy link
Contributor

Hi @divya1c, unfortunately we don't support collision detection for non-symbol layers -- although I understand that in this case you'd want the circle layer to behave as if it were a symbol layer.

I chose circles to icons for my layer 2 since the color changes with a property.

Is there a reason you couldn't use the icon-color property on a circle-shaped icon to achieve something similar?

@ChrisLoer
Copy link
Contributor

Oops, I missed @ansis had already commented! 😅

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

No branches or pull requests

3 participants