mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Do not hide markers at specified zoom level?

Open misterfresh opened this issue 11 years ago • 14 comments

I have a map where I set maxZoom at 9. At the moment for testing purposes I would like to show all markers at that zoom level, even if they overlap.

How can I do that?

Thanks.

misterfresh avatar Mar 17 '15 12:03 misterfresh

See icon-allow-overlap in the style spec https://www.mapbox.com/mapbox-gl-style-spec/#symbol

mourner avatar Mar 17 '15 13:03 mourner

Thanks.

With the following code markers still can't seem to overlap :

    var style = require('./../../conf/outdoors-v7.json');
    style.layers.push({
        "id": "markers",
        "type": "symbol",
        "source": "markers",
        "layout": {
            "icon-image": "{marker-symbol}-12",
            "icon-allow-overlap": true,
            "icon-ignore-placement": true,
            "text-field": "{title}",
            "text-font": "Open Sans Semibold, Arial Unicode MS Bold",
            "text-offset": [0, 0.6],
            "text-anchor": "top"
        },
        "paint": {
            "text-size": 12
        }
    });

misterfresh avatar Mar 17 '15 23:03 misterfresh

This is an old thread but in case anyone else runs into this issue -

you also have to add 'text-allow-overlap': true, probably because your layer has text-field property and if it is not set, mapbox somehow ignores icon-allow-overlap: true and hides icons anyway.

SimonaJ avatar Sep 29 '16 13:09 SimonaJ

@SimonaJ in my case I don't even have text. Just an icon. But still most of my icons are not visible (up to a certain zoom level) even though they are 'miles away' from other icons. This is what I have now. Would appreciate any hints.

map.addLayer({
      id: constants.MAP_LAYER_ID,
      type: 'symbol',
      source: constants.MAP_SOURCE_DATA_ID,
      layout: {
          'icon-image': 'monument-15',
          'icon-allow-overlap': true,
          'icon-ignore-placement': true,
          'icon-padding': 0,
          'text-allow-overlap': true // doesnt make sense I know, but I tried this
      }
  });

haffla avatar Oct 26 '16 11:10 haffla

I'm also finding this. Do the docs hide a clue? image What exactly does data-driven styling mean? As this isn't supported yet.

sidonaldson avatar May 03 '17 12:05 sidonaldson

@haffla when you add your source, do not add this option:

cluster: true

or set it to false:

                    map.addSource("shops", {
                        type: "geojson",
                        data: your_data
                    });

woshitom avatar Jan 04 '18 19:01 woshitom

run into this problem, too.

My code as following:

layout: { "icon-image": "my-icon", "icon-allow-overlap": true, "icon-padding": 1, "icon-size": 0.8, "text-allow-overlap": true, "icon-ignore-placement": true , }

In fact, there's no text at all. But still most of my icons are not visible (up to a certain zoom level) even though they are 'miles away' from other icons.

liushengxian avatar Mar 14 '18 07:03 liushengxian

Anyone finding a solution for this? I am facing the same issue.

{
    id: source,
    source: source,
    type: 'symbol',
    interactive: true,
    layout: {
      'icon-image': 'someiamge'
      'icon-allow-overlap': true,
      'symbol-avoid-edges': true,
      'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
      'text-size': 8,
      'text-transform': 'uppercase',
      'text-letter-spacing': 0.05,
      'text-offset': [0, 1.3],
    },
    paint: {
      'text-color': '#ffffff',
    },
  }

leogoesger avatar May 23 '18 23:05 leogoesger

I solved my issue by adding 'text-allow-overlap': true, and 'icon-allow-overlap': true,.

leogoesger avatar May 23 '18 23:05 leogoesger

@leogoesger How could I add have a box with background like a box to show textField on it?

jsina avatar Jun 04 '18 17:06 jsina

It's probably caused by the source, not the style. In the source tile there are distributed to several zoom levels, so, you can't see them all in one zoom level

zhuxiaomengjj avatar Dec 14 '18 04:12 zhuxiaomengjj

In my case switching from 'symbol-placement': 'line' to 'symbol-placement': 'line-center' helped.

hb0 avatar Jun 19 '19 09:06 hb0

Sorry for resurrecting this but this was also very helpful for me

https://stackoverflow.com/a/60556654/2078468

TL;DR sometimes an icons visibility is not defined by styling but by whether that geographical feature exists in the underlying map tiles for that specific zoom level

rico-ocepek avatar Aug 30 '23 08:08 rico-ocepek

how can we use this in iOS SDK?

vijaykharage7 avatar Aug 22 '24 09:08 vijaykharage7