question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Symbol Layer Icons become hidden with textfield

See original GitHub issue

Hi,

We are using SymbolLayer Infow Window code from the following url:

https://github.com/mapbox/mapbox-android-demo/blob/master/MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/InfoWindowSymbolLayerActivity.java

We have noticed that if we placed the symbols/ markers without TextField then the mapbox display more icons on the screen. For example if have we total 10 icons then on a specific zoom level without textfield, we can see 5 to 6 six icons. But with a textField the mapbox show only 2 to 3 icons, means it shows less icons. While we zoom in the map, then rest of the icons also displayed. Why the icons become hidden at the same zoom level? As we zoom out the map, the icons going to disappear, and shown again as we zoom in.

Any idea. Please see the following code.

if (isMarkerNameShowing) {
                    style.addLayer(new SymbolLayer(MARKER_LAYER_ID, GEOJSON_SOURCE_ID)
                            .withProperties(
                                    iconImage("{markercolor}"),
                                    PropertyFactory.textField("{name}"),
                                    PropertyFactory.textColor(Color.RED),
                                    PropertyFactory.textOffset(new Float[]{0f, 1f}),
                                    PropertyFactory.iconIgnorePlacement(true),
                                    iconAllowOverlap(false),
                                    iconOffset(new Float[]{0f, -8f})
                            ));
                } else {
                    style.addLayer(new SymbolLayer(MARKER_LAYER_ID, GEOJSON_SOURCE_ID)
                            .withProperties(
                                    iconImage("{markercolor}"),
                                    PropertyFactory.iconIgnorePlacement(true),
                                    iconAllowOverlap(false),
                                    iconOffset(new Float[]{0f, -8f})
                            ));
                }

Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
langsmithcommented, Oct 3, 2019
1reaction
mortezahosseineecommented, Dec 22, 2019

Hi, i wrote these lines of code based on mapbox-android-plugin-annotation-v8:0.7.0’ tutorial:

private void addSymbolToMap() {
        mapStyle.addImage("sample_image_id", getResources().getDrawable(R.drawable.mapbox_marker_icon_default));

        // create symbol manager object
        SymbolManager sampleSymbolManager = new SymbolManager(mapView, map, mapStyle);

        // set non-data-driven properties, such as:
        sampleSymbolManager.setIconAllowOverlap(true);
        sampleSymbolManager.setIconRotationAlignment(ICON_ROTATION_ALIGNMENT_VIEWPORT);

        // Add symbol at specified lat/lon
        SymbolOptions sampleSymbolOptions = new SymbolOptions()
                .withLatLng(samplePoint)
                .withIconImage("sample_image_id")
                .withIconSize(1f);

        // save created Symbol Object for later access
        Symbol sampleSymbol = sampleSymbolManager.create(sampleSymbolOptions);
    }

then, i saw my icon in defined latLng, but after i add this line of code: withTextField(“my text”), symbol icon disappears and not see any text on map. help me. result code after add that line of code:

private void addSymbolToMap() {
        mapStyle.addImage("sample_image_id", getResources().getDrawable(R.drawable.mapbox_marker_icon_default));

        // create symbol manager object
        SymbolManager sampleSymbolManager = new SymbolManager(mapView, map, mapStyle);

        // set non-data-driven properties, such as:
        sampleSymbolManager.setIconAllowOverlap(true);
        sampleSymbolManager.setIconRotationAlignment(ICON_ROTATION_ALIGNMENT_VIEWPORT);

        // Add symbol at specified lat/lon
        SymbolOptions sampleSymbolOptions = new SymbolOptions()
                .withLatLng(samplePoint)
                .withIconImage("sample_image_id")
                .withIconSize(1f)
                .withTextField("hi you");

        // save created Symbol Object for later access
        Symbol sampleSymbol = sampleSymbolManager.create(sampleSymbolOptions);
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to hide point labels at certain zoom levels in mapbox-gl-js?
I now add one layer that only shows the icons, and also add a second layer that only contains the labels. In this...
Read more >
Add a Symbol layer to a map - Azure - Microsoft Learn
By default, symbol layers optimize the rendering of symbols by hiding symbols that overlap. As you zoom in, the hidden symbols become visible....
Read more >
Icons appearing over a text box in their Normal states...
After reading the scenario, the user is instructed to double-click inside the text box in order for it to become Hidden again. They...
Read more >
Layers | Style Specification | Mapbox GL JS
At zoom levels less than the minzoom, the layer will be hidden. ... corresponding icons when the icon collides with other symbols and...
Read more >
The One Trick You Need to Master Sketch Layout🦸🏻‍♀️
By combining layer & text styles with Sketch's smart layout, ... Go to Symbols screen and make sure that you allow overrides for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found