List of usage examples for com.google.gwt.maps.client MapOptions setStreetViewControl
public final native void setStreetViewControl(boolean streetViewControl) ;
From source file:com.google.gwt.maps.testing.client.maps.ImageMapTypeWidget.java
License:Apache License
private void drawMap() { // make custom maps ImageMapType moonType = getMoonMapType(); ImageMapType marsType = getMarsMapType(); // draw map/* w w w. j a v a2s. com*/ MapTypeControlOptions controlOpts = MapTypeControlOptions.newInstance(); //TODO How it make it label as "Earth" not "Satellite" without redefining that standard map type? controlOpts.setMapTypeIds(new String[] { LUNAR_NAME, MARTIAN_NAME, MapTypeId.SATELLITE.toString() }); MapOptions opts = MapOptions.newInstance(); opts.setCenter(LatLng.newInstance(-12d, -70d)); opts.setZoom(7); opts.setMapTypeControlOptions(controlOpts); opts.setStreetViewControl(false); mapWidget = new MapWidget(opts); mapWidget.setSize("750px", "500px"); // add to map mapWidget.getMapTypeRegistry().set(MARTIAN_NAME, marsType); mapWidget.getMapTypeRegistry().set(LUNAR_NAME, moonType); mapWidget.setMapTypeId(MARTIAN_NAME); pWidget.add(mapWidget); }
From source file:com.google.gwt.maps.testing.client.maps.MultipleKmlMapWidget.java
License:Apache License
private void drawMap() { LatLng center = LatLng.newInstance(46.649436, 2.633423); MapOptions opts = MapOptions.newInstance(); opts.setZoom(6);//from w w w . ja va 2 s . c om opts.setCenter(center); opts.setMapTypeId(MapTypeId.TERRAIN); opts.setStreetViewControl(false); opts.setPanControl(false); opts.setZoomControl(false); mapWidget = new MapWidget(opts); pWidget.add(mapWidget); mapWidget.setSize("750px", "500px"); }
From source file:gov.nist.spectrumbrowser.client.SpectrumBrowserShowDatasets.java
License:Open Source License
public void draw() { try {// www. j a va 2 s.c om spectrumBrowser.showWaitImage(); Window.setTitle("MSOD:Home"); SpectrumBrowser.clearSensorInformation(); sensorMarkers.clear(); SensorGroupMarker.clear(); verticalPanel.clear(); navigationBar = new MenuBar(); navigationBar.clearItems(); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.add(navigationBar); HorizontalPanel mapAndSensorInfoPanel = new HorizontalPanel(); mapAndSensorInfoPanel.setStyleName("mapAndSensorInfoPanel"); HTML html = new HTML("<h2>" + END_LABEL + "</h2> ", true); verticalPanel.add(html); String help = "Click on a sensor marker to select it. " + "Then select start date and and duration of interest."; helpLabel = new Label(); helpLabel.setText(help); verticalPanel.add(helpLabel); ScrollPanel scrollPanel = new ScrollPanel(); scrollPanel.setHeight(SpectrumBrowser.MAP_WIDTH + "px"); scrollPanel.setStyleName("sensorInformationScrollPanel"); sensorInfoPanel = new VerticalPanel(); sensorInfoPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); scrollPanel.add(sensorInfoPanel); sensorInfoPanel.setStyleName("sensorInfoPanel"); mapAndSensorInfoPanel.add(scrollPanel); selectionGrid = new Grid(1, 10); selectionGrid.setStyleName("selectionGrid"); selectionGrid.setVisible(false); for (int i = 0; i < selectionGrid.getRowCount(); i++) { for (int j = 0; j < selectionGrid.getColumnCount(); j++) { selectionGrid.getCellFormatter().setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER); selectionGrid.getCellFormatter().setVerticalAlignment(i, j, HasVerticalAlignment.ALIGN_MIDDLE); } } verticalPanel.add(selectionGrid); sensorInfoPanel.clear(); //sensorInfoPanel.setTitle("Click on marker to select sensors."); Label selectedMarkersLabel = new Label(); selectedMarkersLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); selectedMarkersLabel.setText("Sensor Information Display"); selectedMarkersLabel.getElement().getStyle().setCursor(Cursor.TEXT); selectedMarkersLabel.setStyleName("selectedMarkersLabel"); sensorInfoPanel.add(selectedMarkersLabel); if (map == null) { MapOptions mapOptions = MapOptions.newInstance(true); mapOptions.setMaxZoom(15); mapOptions.setMinZoom(3); mapOptions.setStreetViewControl(false); map = new MapWidget(mapOptions); //map.setTitle("Click on a marker to display information about a sensor."); map.setSize(SpectrumBrowser.MAP_WIDTH + "px", SpectrumBrowser.MAP_HEIGHT + "px"); } else if (map.getParent() != null) { map.removeFromParent(); } mapAndSensorInfoPanel.add(map); verticalPanel.add(mapAndSensorInfoPanel); logger.finer("getLocationInfo"); spectrumBrowser.getSpectrumBrowserService().getLocationInfo(SpectrumBrowser.getSessionToken(), new SpectrumBrowserCallback<String>() { @Override public void onFailure(Throwable caught) { logger.log(Level.SEVERE, "Error in processing request", caught); verticalPanel.clear(); if (spectrumBrowser.isUserLoggedIn()) { Window.alert("The system is down for maintenance. Please try again later.\n" + caught.getMessage()); spectrumBrowser.logoff(); } else { HTML error = new HTML( "<h1>The System is down for maintenance. Please try later.</h1>"); verticalPanel.add(error); HTML errorMsg = new HTML("<h2>" + caught.getMessage() + "</h2>"); verticalPanel.add(errorMsg); } } @Override public void onSuccess(String jsonString) { try { logger.finer(jsonString); JSONObject jsonObj = (JSONObject) JSONParser.parseLenient(jsonString); String baseUrl = SpectrumBrowser.getBaseUrlAuthority(); addSensor(jsonObj, baseUrl); logger.finer("Added returned sensors. Dealing with peers"); // Now deal with the peers. final JSONObject peers = jsonObj.get("peers").isObject(); // By definition, peers do not need login but we need a session // Key to talk to the peer so go get one. for (String url : peers.keySet()) { logger.finer("Showing sensors for Peer " + url); final String peerUrl = url; spectrumBrowser.getSpectrumBrowserService().isAuthenticationRequired(url, new SpectrumBrowserCallback<String>() { @Override public void onSuccess(String result) { JSONObject jobj = JSONParser.parseLenient(result).isObject(); boolean authRequired = jobj.get("AuthenticationRequired") .isBoolean().booleanValue(); if (!authRequired) { String sessionToken = jobj.get("SessionToken").isString() .stringValue(); SpectrumBrowser.setSessionToken(peerUrl, sessionToken); JSONObject peerObj = peers.get(peerUrl).isObject(); addSensor(peerObj, peerUrl); } } @Override public void onFailure(Throwable throwable) { logger.log(Level.SEVERE, "Could not contact peer at " + peerUrl, throwable); } }); } final Timer timer = new Timer() { @Override public void run() { if (getMap().isAttached()) { spectrumBrowser.hideWaitImage(); showMarkers(); cancel(); } } }; timer.scheduleRepeating(500); populateMenuItems(); map.addZoomChangeHandler(new ZoomChangeMapHandler() { @Override public void onEvent(ZoomChangeMapEvent event) { SensorGroupMarker.showMarkers(); } }); } catch (Exception ex) { logger.log(Level.SEVERE, "Error ", ex); spectrumBrowser.displayError("Error parsing json response"); } } } ); } catch (Exception ex) { logger.log(Level.SEVERE, "Error in displaying data sets", ex); } }
From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java
License:Open Source License
public VesselWatchMapViewGwtImpl() { initWidget(uiBinder.createAndBindUi(this)); accessibilityPrepare();//from w w w.j a v a 2 s . c o m if (MGWT.getOsDetection().isAndroid()) { leftFlexSpacer.setVisible(false); } if (localStorage != null) { storageMap = new StorageMap(localStorage); if (!storageMap.containsKey("KEY_SHOW_CAMERAS")) { localStorage.setItem("KEY_SHOW_CAMERAS", "true"); // Set initial default value } // Set initial default location and zoom to Seattle area. localStorage.setItem("KEY_MAP_LAT", "47.565125"); localStorage.setItem("KEY_MAP_LON", "-122.480508"); localStorage.setItem("KEY_MAP_ZOOM", "11"); } final TrafficLayer trafficLayer = TrafficLayer.newInstance(); LatLng center = LatLng.newInstance(Double.valueOf(localStorage.getItem("KEY_MAP_LAT")), Double.valueOf(localStorage.getItem("KEY_MAP_LON"))); MapOptions opts = MapOptions.newInstance(); opts.setMapTypeId(MapTypeId.ROADMAP); opts.setCenter(center); opts.setZoom(Integer.valueOf(localStorage.getItem("KEY_MAP_ZOOM"), 10)); opts.setPanControl(false); opts.setZoomControl(false); opts.setMapTypeControl(false); opts.setScaleControl(false); opts.setStreetViewControl(false); opts.setOverviewMapControl(false); // Custom map style to remove all "Points of Interest" labels from map MapTypeStyle style1 = MapTypeStyle.newInstance(); style1.setFeatureType(MapTypeStyleFeatureType.POI); style1.setElementType(MapTypeStyleElementType.LABELS); style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newVisibilityStyler("off") }); MapTypeStyle[] styles = { style1 }; opts.setMapTypeStyles(styles); mapWidget = new MyMapWidget(opts); trafficLayer.setMap(mapWidget); flowPanel.add(mapWidget); mapWidget.setSize(Window.getClientWidth() + "px", (Window.getClientHeight() - ParserUtils.windowUI()) + "px"); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { MapHandlerRegistration.trigger(mapWidget, MapEventType.RESIZE); } }); mapWidget.addResizeHandler(new ResizeMapHandler() { @Override public void onEvent(ResizeMapEvent event) { mapWidget.setSize(Window.getClientWidth() + "px", (Window.getClientHeight() - ParserUtils.windowUI()) + "px"); } }); mapWidget.addIdleHandler(new IdleMapHandler() { @Override public void onEvent(IdleMapEvent event) { localStorage.setItem("KEY_MAP_LAT", String.valueOf(mapWidget.getCenter().getLatitude())); localStorage.setItem("KEY_MAP_LON", String.valueOf(mapWidget.getCenter().getLongitude())); localStorage.setItem("KEY_MAP_ZOOM", String.valueOf(mapWidget.getZoom())); if (presenter != null) { presenter.onMapIsIdle(); } } }); }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
public TrafficMapViewGwtImpl() { initWidget(uiBinder.createAndBindUi(this)); accessibilityPrepare();/*w w w .j av a 2 s .c o m*/ if (MGWT.getOsDetection().isAndroid()) { leftFlexSpacer.setVisible(false); } if (localStorage != null) { storageMap = new StorageMap(localStorage); if (!storageMap.containsKey("KEY_SHOW_CAMERAS")) { localStorage.setItem("KEY_SHOW_CAMERAS", "true"); // Set initial default value } if (!storageMap.containsKey("KEY_SHOW_RESTAREAS")) { localStorage.setItem("KEY_SHOW_RESTAREAS", "false"); // Set initial default value } // Set initial default location and zoom to Seattle area. if (!storageMap.containsKey("KEY_MAP_LAT")) { localStorage.setItem("KEY_MAP_LAT", "47.5990"); } if (!storageMap.containsKey("KEY_MAP_LON")) { localStorage.setItem("KEY_MAP_LON", "-122.3350"); } if (!storageMap.containsKey("KEY_MAP_ZOOM")) { localStorage.setItem("KEY_MAP_ZOOM", "12"); } } final TrafficLayer trafficLayer = TrafficLayer.newInstance(); LatLng center = LatLng.newInstance(Double.valueOf(localStorage.getItem("KEY_MAP_LAT")), Double.valueOf(localStorage.getItem("KEY_MAP_LON"))); MapOptions opts = MapOptions.newInstance(); opts.setMapTypeId(MapTypeId.ROADMAP); opts.setCenter(center); opts.setZoom(Integer.valueOf(localStorage.getItem("KEY_MAP_ZOOM"), 10)); opts.setPanControl(false); opts.setZoomControl(false); opts.setMapTypeControl(false); opts.setScaleControl(false); opts.setStreetViewControl(false); opts.setOverviewMapControl(false); // Custom map style to remove all "Points of Interest" labels from map MapTypeStyle style1 = MapTypeStyle.newInstance(); style1.setFeatureType(MapTypeStyleFeatureType.POI); style1.setElementType(MapTypeStyleElementType.LABELS); style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newVisibilityStyler("off") }); MapTypeStyle[] styles = { style1 }; opts.setMapTypeStyles(styles); mapWidget = new MyMapWidget(opts); trafficLayer.setMap(mapWidget); flowPanel.add(mapWidget); mapWidget.setSize(Window.getClientWidth() + "px", (Window.getClientHeight() - ParserUtils.windowUI()) + "px"); Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { MapHandlerRegistration.trigger(mapWidget, MapEventType.RESIZE); } }); mapWidget.addResizeHandler(new ResizeMapHandler() { @Override public void onEvent(ResizeMapEvent event) { mapWidget.setSize(Window.getClientWidth() + "px", (Window.getClientHeight() - ParserUtils.windowUI()) + "px"); } }); mapWidget.addIdleHandler(new IdleMapHandler() { @Override public void onEvent(IdleMapEvent event) { localStorage.setItem("KEY_MAP_LAT", String.valueOf(mapWidget.getCenter().getLatitude())); localStorage.setItem("KEY_MAP_LON", String.valueOf(mapWidget.getCenter().getLongitude())); localStorage.setItem("KEY_MAP_ZOOM", String.valueOf(mapWidget.getZoom())); if (presenter != null) { presenter.onMapIsIdle(); } } }); }
From source file:net.cbtltd.client.field.MapField.java
/** * Instantiates a new map field./*from ww w. j a va2s. c om*/ * * @param form is the form or other HasComponents element that contains the field. * @param permission that controls the visibility of the field. * @param tab index of the field. */ public MapField(HasComponents form, short[] permission, int tab) { initialize(panel, form, permission, CSS.cbtMapField()); super.setDefaultValue(LatLng.newInstance(0.0, 0.0)); addressLabel.addStyleName(CSS.cbtMapFieldLabel()); addressBox.addStyleName(CSS.cbtLocationFieldField()); addressBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { setName(addressBox.getText()); } }); addressBox.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { setName(addressBox.getText()); } } }); latitudeLabel.addStyleName(CSS.cbtMapFieldLabel()); latitudeBox.addStyleName(CSS.cbtMapFieldLatLng()); latitudeBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Double latitude = LF.parse(latitudeBox.getText()); if (latitude < -90.0 || latitude > 90.0) { addMessage(Level.ERROR, CONSTANTS.errPositionLatitude(), latitudeBox); } else { setValue(LatLng.newInstance(latitude, marker.getPosition().getLongitude())); } } }); longitudeLabel.addStyleName(CSS.cbtMapFieldLabel()); longitudeBox.addStyleName(CSS.cbtMapFieldLatLng()); longitudeBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Double longitude = LF.parse(longitudeBox.getText()); if (longitude < -180.0 || longitude > 180.0) { addMessage(Level.ERROR, CONSTANTS.errPositionLongitude(), longitudeBox); } else { setValue(LatLng.newInstance(marker.getPosition().getLatitude(), longitude)); } } }); position.addStyleName(CSS.cbtMapFieldTitle()); position.add(addressLabel); position.add(addressBox); position.add(latitudeLabel); position.add(latitudeBox); position.add(longitudeLabel); position.add(longitudeBox); position.add(lock); panel.add(position); MapOptions mapOptions = MapOptions.newInstance(); mapOptions.setDraggableCursor("crosshair"); mapOptions.setDraggingCursor("text"); mapOptions.setCenter(LatLng.newInstance(0.0, 0.0)); mapOptions.setDraggable(true); mapOptions.setDisableDoubleClickZoom(true); // mapOptions.setHeading(heading); mapOptions.setKeyboardShortcuts(false); mapOptions.setMapMaker(true); mapOptions.setMapTypeControl(true); mapOptions.setMapTypeId(mapTypeId); mapOptions.setNoClear(false); mapOptions.setOverviewMapControl(false); // mapOptions.setMapTypeControlOptions(MapTypeControlOptions.) mapOptions.setPanControl(true); // mapOptions.setPanControlOptions(panControlOptions); mapOptions.setRotateControl(false); // mapOptions.setRotateControlOptions(rotateControlOptions) mapOptions.setScaleControl(true); // mapOptions.setScaleControlOptions(scaleControlOptions) mapOptions.setScrollWheel(scrollWheel); // StreetViewPanoramaImpl streetView = StreetViewPanoramaImpl.newInstance(field.getElement(), options); // mapOptions.setStreetView(streetView); mapOptions.setStreetViewControl(streetView); // mapOptions.setStreetViewControlOptions(streetViewControlOptions) // mapOptions.setStyles(styles) mapOptions.setZoom(15); mapOptions.setZoomControl(true); map = MapWidget.newInstance(MapImpl.newInstance(field.getElement(), mapOptions)); map.addClickHandler(new ClickMapHandler() { public void onEvent(ClickMapEvent event) { if (isEnabled()) { setValue(event.getMouseEvent().getLatLng()); fireChange(MapField.this); } } }); panel.add(field); emptyValue.addStyleName(CSS.cbtMapFieldEmpty()); emptyValue.setVisible(false); panel.add(emptyValue); InfoWindowOptions infowindowOpts = InfoWindowOptions.newInstance(); infowindowOpts.setMaxWidth(100); infowindowOpts.setPosition(defaultValue); infoWindow = InfoWindow.newInstance(infowindowOpts); }
From source file:pl.itrack.client.local.services.maps.TricitySchemaService.java
License:Apache License
@Override public MapOptions getMapOptions() { MapTypeControlOptions controlOpts = MapTypeControlOptions.newInstance(); controlOpts.setMapTypeIds(new String[] { MAP_TYPE_ID }); MapOptions opts = MapOptions.newInstance(); opts.setZoom(ZOOM_INITIAL);//from w ww . j a v a2 s . c o m opts.setMapTypeControlOptions(controlOpts); opts.setPanControl(false); opts.setStreetViewControl(false); opts.setBackgroundColor(BACKGROUND_COLOR); opts.setCenter(LatLng.newInstance(INITIAL_LATITUDE, INITIAL_LONGITUDE)); return opts; }