Search code examples
javagoogle-maps-api-3jxmaps

JxMaps possibility to disable Google's default POI


with JxMaps I can show a Google-Map window within Java Swing.

When zooming in, Google shows much details as Restaurants and Shops. I also can click on those Restaurants and Shops - but that's something I don't want to have in my application.

Anyone having an idea on how to disable it?

I think it might be possible when setting map options:

            // Getting the associated map object
            map = getMap();
            // Creating a map options object
            MapOptions mapOptions = new MapOptions();
            // Creating a map type control options object
            MapTypeControlOptions controlOptions = new MapTypeControlOptions();
            // Changing position of the map type control
            controlOptions.setPosition(ControlPosition.TOP_RIGHT);
            // Setting map type control options
            mapOptions.setMapTypeControlOptions(controlOptions);
            // Setting map options
            map.setOptions(mapOptions);

But I cant find an appropriate option.

Thank you very much


Solution

  • MapOptions doesn't have property that allows to hide POI. But you can create custom map style with hidden default POI. Please take a look example below:

    MapTypeStyler styler = new MapTypeStyler();
    styler.setVisibility("off");
    
    MapTypeStyle style = new MapTypeStyle();
    style.setElementType(MapTypeStyleElementType.ALL);
    style.setFeatureType(MapTypeStyleFeatureType.POI);
    style.setStylers(new MapTypeStyler[]{styler});
    
    StyledMapType styledMap = new StyledMapType(map, new MapTypeStyle[]{style});
    map.mapTypes().set("newStyle", styledMap);
    map.setMapTypeId(new MapTypeId("newStyle"));