Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable streetview using gwt?

There is a "person" icon which allows user to view "Street View". I don't want this functionality on my map, is there a way to remove it or disable it? And I am not using JavaScript I am doing it using GWT.

Google-Maps v3 am using.

private void initMap() {
        mapVp.setSize(String.valueOf(BodyPanel.bodyWidth - 505),
                String.valueOf(BodyPanel.bodyHeight + 5));
        LatLng myLatLng = LatLng.create(24.440099, 46.843498);
        final MapOptions myOptions = MapOptions.create();
        myOptions.setZoom(5);
        myOptions.setCenter(myLatLng);
        setStreetViewControl(myOptions.getJso(), false); //Added now
        myOptions.setMapTypeId(MapTypeId.ROADMAP);
        myOptions.setMapTypeControl(true);
        Timer load = new Timer() {

            @Override
            public void run() {
                map = GoogleMap.create(mapVp.getElement(), myOptions);
                hPanel.add(LoginDashboardModule
                        .mapLegends(map, "Live Tracking"));
            }
        };
        load.schedule(1000);        
    }

This is my code I am getting error after adding this line setStreetViewControl(myOptions.getJso(), false);

like image 308
Ibadur Rahman K Avatar asked Jan 27 '26 13:01

Ibadur Rahman K


2 Answers

I just used the line below and got the output.

myOptions.setStreetViewControl(false);

like image 161
Ibadur Rahman K Avatar answered Jan 29 '26 10:01

Ibadur Rahman K


You can do this with JSNI.

public static MapWidget createMapWidget(double lat, double lng,
        final String width, final String height, int zoomLevel) {
    // Set the options of the map widget.
    MapOptions options = new MapOptions();
    options.setZoom(zoomLevel);
    options.setMapTypeId(new MapTypeId().getRoadmap());
    setStreetViewControl(options.getJso(), false);
    options.setCenter(new LatLng(lat, lng));

    /* The map widget */
    final MapWidget mapWidget = new MapWidget(options);
    mapWidget.setWidth(width);
    mapWidget.setHeight(height);
    return mapWidget;
}

public static native void setStreetViewControl(JavaScriptObject obj,
        boolean control) /*-{
    if (obj)
        obj.streetViewControl = control;
}-*/;
like image 38
Patrice De Saint Steban Avatar answered Jan 29 '26 09:01

Patrice De Saint Steban