List of usage examples for com.google.gwt.maps.client MapWidget MapWidget
MapWidget
From source file:com.apress.progwt.client.map.CollegeMapApp.java
License:Apache License
public CollegeMapApp(int pageID) { super(pageID); try {// w ww . j a v a 2 s . co m Log.debug("In CollegeBound"); double latitude = Double.parseDouble(getParam("latitude")); double longitude = Double.parseDouble(getParam("longitude")); LatLng collegeCenter = new LatLng(latitude, longitude); if (latitude == -1 && longitude == -1) { map = new MapWidget(); } else { map = new MapWidget(collegeCenter, DEFAULT_ZOOM); } map.setSize("300px", "250px"); map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); map.setScrollWheelZoomEnabled(true); map.clearOverlays(); map.addOverlay(new Marker(collegeCenter)); Log.debug("Show CollegeBound"); show(map); } catch (Exception e) { Log.error("EX " + e); loadError(e); } }
From source file:com.claudiushauptmann.gwt.maps.gxt.samples.client.OverlayEditor.java
License:Apache License
public void onModuleLoad() { // Map// w w w . j ava2 s . com mapWidget = new MapWidget(); mapWidget.setCenter(LatLng.newInstance(48.136559, 11.576318), 13); mapWidget.setWidth("100%"); mapWidget.setHeight("100%"); mapWidget.addControl(new LargeMapControl()); mapWidget.setContinuousZoom(true); mapWidget.setScrollWheelZoomEnabled(true); RootPanel.get().add(mapWidget); // MapController mapGxtController = new MapGXTController(mapWidget); mapMenuProvider = new MapMenuProvider(); mapGxtController.setMenuProvider(mapMenuProvider); // Marker MarkerOptions mo = MarkerOptions.newInstance(); mo.setClickable(true); mo.setDraggable(true); Marker marker = new Marker(mapWidget.getCenter(), mo); mapWidget.addOverlay(marker); new MyMarkerEditController(mapGxtController, marker, "Marienplatz", "Marienplatz is a central square in the" + " city center of Munich, Germany since 1158.<br/>" + " In the Middle Ages markets and tournaments were held in this" + " city square. The Glockenspiel in the new city hall was inspired" + " by these tournaments, and draws millions of tourists a year."); // Polyline LatLng[] llline = new LatLng[3]; llline[0] = LatLng.newInstance(48.131955, 11.527061); llline[1] = LatLng.newInstance(48.11809, 11.579247); llline[2] = LatLng.newInstance(48.127143, 11.638298); PolylineOptions plo = PolylineOptions.newInstance(true, false); Polyline line = new Polyline(llline, "#FF0000", 2, 1.0, plo); mapWidget.addOverlay(line); new MyPolylineEditController(mapGxtController, line, "Polyline", "This is a polyline."); // Polygon LatLng[] llpolygon = new LatLng[4]; llpolygon[0] = LatLng.newInstance(48.119809, 11.539936); llpolygon[1] = LatLng.newInstance(48.158185, 11.541138); llpolygon[2] = LatLng.newInstance(48.155894, 11.569118); llpolygon[3] = llpolygon[0]; PolygonOptions pgo = PolygonOptions.newInstance(true); Polygon polygon = new Polygon(llpolygon, "#0000FF", 2, 1.0, "#0000FF", 0.3, pgo); mapWidget.addOverlay(polygon); new MyPolygonEditController(mapGxtController, polygon, "Polygon", "This is a polygon."); }
From source file:com.google.gwt.gadgets.sample.traveler.client.TravelMap.java
License:Apache License
private TravelMap(boolean doubleClickToZoom) { map = new MapWidget(); map.setSize("100%", "100%"); map.setCenter(zero, 0);//from ww w. j a v a 2 s . c o m MapUIOptions options = MapUIOptions.newInstance(Size.newInstance(200, 200)); options.setDoubleClick(doubleClickToZoom); map.setUI(options); DockLayoutPanel panel = new DockLayoutPanel(Unit.PCT); panel.add(map); initWidget(panel); }
From source file:com.google.gwt.maps.sample.hellomaps.client.SimpleDemo.java
License:Apache License
public SimpleDemo() { map = new MapWidget(); map.setSize("500px", "300px"); initWidget(map); }
From source file:com.google.livingstories.client.contentmanager.ContentItemManager.java
License:Apache License
private Widget createLocationPanel() { final VerticalPanel locationPanel = new VerticalPanel(); // show a map based on geocoded or manually-inputted lat-long combination HorizontalPanel descriptionPanel = new HorizontalPanel(); descriptionPanel.add(new HTML("Location name (displayed to readers):")); locationDescriptionTextArea = new TextArea(); locationDescriptionTextArea.setCharacterWidth(50); locationDescriptionTextArea.setHeight("60px"); descriptionPanel.add(locationDescriptionTextArea); Label geocodingOptions = new Label("Geocode based on:"); useDisplayedLocation = new RadioButton("geoGroup", "The displayed location name"); useDisplayedLocation.setValue(true); useAlternateLocation = new RadioButton("geoGroup", "An alternate location that geocodes better: "); alternateTextBox = new TextBox(); alternateTextBox.setEnabled(false);/*from w w w .ja v a2 s . c om*/ HorizontalPanel alternatePanel = new HorizontalPanel(); alternatePanel.add(useAlternateLocation); alternatePanel.add(alternateTextBox); useManualLatLong = new RadioButton("geoGroup", "Manually entered latitude and longitude numbers (enter these below)"); HorizontalPanel latLongPanel = new HorizontalPanel(); latLongPanel.add(new HTML("Latitude: ")); latitudeTextBox = new TextBox(); latitudeTextBox.setEnabled(false); latLongPanel.add(latitudeTextBox); latLongPanel.add(new HTML(" Longitude: ")); longitudeTextBox = new TextBox(); longitudeTextBox.setEnabled(false); latLongPanel.add(longitudeTextBox); HorizontalPanel buttonPanel = new HorizontalPanel(); geocodeButton = new Button("Geocode location"); geocodeButton.setEnabled(false); buttonPanel.add(geocodeButton); geocoderStatus = new Label(""); buttonPanel.add(geocoderStatus); AjaxLoaderOptions options = AjaxLoaderOptions.newInstance(); options.setOtherParms(mapsKey + "&sensor=false"); AjaxLoader.loadApi("maps", "2", new Runnable() { @Override public void run() { map = new MapWidget(); map.setSize(MAP_WIDTH + "px", MAP_HEIGHT + "px"); map.addControl(new SmallMapControl()); map.setDoubleClickZoom(true); map.setDraggable(true); map.setScrollWheelZoomEnabled(true); map.setZoomLevel(MAP_ZOOM); map.setVisible(false); locationPanel.add(map); createLocationHandlers(); } }, options); locationPanel.add(descriptionPanel); locationPanel.add(geocodingOptions); locationPanel.add(useDisplayedLocation); locationPanel.add(alternatePanel); locationPanel.add(useManualLatLong); locationPanel.add(latLongPanel); locationPanel.add(buttonPanel); locationPanel.add(new Label("Tip: once the map is visible, right-click a point on the map to indicate that" + " this is the precise location you want")); DisclosurePanel locationZippy = new DisclosurePanel("Location"); locationZippy.add(locationPanel); return locationZippy; }
From source file:com.google.livingstories.plugins.wordpress.livingstorypropertymanager.client.ui.LocationInput.java
License:Apache License
private Widget createLocationPanel(final Location location) { final VerticalPanel locationPanel = new VerticalPanel(); if (mapsKeyExists) { HorizontalPanel descriptionPanel = new HorizontalPanel(); descriptionPanel.add(new HTML("Location name (displayed to readers):")); locationDescriptionTextArea = new TextArea(); locationDescriptionTextArea.setName("lsp_location_description"); locationDescriptionTextArea.setCharacterWidth(50); locationDescriptionTextArea.setHeight("60px"); descriptionPanel.add(locationDescriptionTextArea); Label geocodingOptions = new Label("Geocode based on:"); useDisplayedLocation = new RadioButton("geoGroup", "The displayed location name"); useDisplayedLocation.setValue(true); useAlternateLocation = new RadioButton("geoGroup", "An alternate location that geocodes better: "); alternateTextBox = new TextBox(); alternateTextBox.setEnabled(false); HorizontalPanel alternatePanel = new HorizontalPanel(); alternatePanel.add(useAlternateLocation); alternatePanel.add(alternateTextBox); useManualLatLong = new RadioButton("geoGroup", "Manually entered latitude and longitude numbers (enter these below)"); HorizontalPanel latLongPanel = new HorizontalPanel(); latLongPanel.add(new HTML("Latitude: ")); latitudeTextBox = new TextBox(); latitudeTextBox.setEnabled(false); latLongPanel.add(latitudeTextBox); latLongPanel.add(new HTML(" Longitude: ")); longitudeTextBox = new TextBox(); longitudeTextBox.setName("lsp_longitude"); longitudeTextBox.setEnabled(false); latLongPanel.add(longitudeTextBox); // Hidden fields are needed to pass the value of the latitude and longitude text boxes to // the PHP code because the text boxes can be disabled. And if they are disabled, their // values can't be accessed. latitudeValue = new Hidden(); latitudeValue.setName("lsp_latitude"); longitudeValue = new Hidden(); longitudeValue.setName("lsp_longitude"); HorizontalPanel buttonPanel = new HorizontalPanel(); geocodeButton = new Button("Geocode location"); geocodeButton.setEnabled(false); buttonPanel.add(geocodeButton);//from w w w.ja v a2 s. c o m geocoderStatus = new Label(""); buttonPanel.add(geocoderStatus); locationPanel.add(descriptionPanel); locationPanel.add(geocodingOptions); locationPanel.add(useDisplayedLocation); locationPanel.add(alternatePanel); locationPanel.add(useManualLatLong); locationPanel.add(latLongPanel); locationPanel.add(buttonPanel); locationPanel.add(new Label("Tip: once the map is visible, right-click a point on the map to" + " indicate that this is the precise location you want")); locationPanel.add(latitudeValue); locationPanel.add(longitudeValue); locationZippy = new DisclosurePanel("Location"); locationZippy.add(locationPanel); // show a map based on geocoded or manually-inputted lat-long combination AjaxLoaderOptions options = AjaxLoaderOptions.newInstance(); options.setOtherParms(mapsKey + "&sensor=false"); AjaxLoader.loadApi("maps", "2", new Runnable() { @Override public void run() { mapsApiReady = true; map = new MapWidget(); map.setSize(MAP_WIDTH + "px", MAP_HEIGHT + "px"); map.addControl(new SmallMapControl()); map.setDoubleClickZoom(true); map.setDraggable(true); map.setScrollWheelZoomEnabled(true); map.setZoomLevel(MAP_ZOOM); map.setVisible(false); locationPanel.add(map); createLocationHandlers(); // Set the provided location on the map, if there is any setLocation(location); // Add handlers to re-center the map when the disclosure panel is toggled, because the // map has trouble centering if it's visibility is changed via the map. The handlers need // to be added here because we want to make sure that the map has been created before // adding the handlers. addDisclosurePanelHandlers(); } }, options); } else { Label noKeyLabel = new Label("Google Maps API key not available. Please specify in" + " the ClientConstants.properties file."); noKeyLabel.setStyleName(Resources.INSTANCE.css().error()); locationPanel.add(noKeyLabel); } return locationZippy; }
From source file:com.ui.gwt.mobile.client.components.DetailPanel.java
License:Apache License
public void buildMap(Contact data) { if (mapWidget == null) { map.addClassName(AppResources.INSTANCE.css().map()); mapWidget = new MapWidget(); mapWidget.setWidth("100%"); mapWidget.setHeight("400px"); geocoder = new Geocoder(); add(mapWidget);// w ww .j a va 2 s . co m } final InfoWindow info = mapWidget.getInfoWindow(); final String address = data.getAddr1() + " " + data.getAddr2(); geocoder.getLatLng(address, new LatLngCallback() { @Override public void onFailure() { } @Override public void onSuccess(LatLng point) { mapWidget.setCenter(point, 13); Marker marker = new Marker(point); mapWidget.clearOverlays(); mapWidget.addOverlay(marker); info.open(marker, new InfoWindowContent(address)); } }); }
From source file:org.onebusaway.webapp.gwt.agencies_map.AgenciesMap.java
License:Apache License
@Override public void onModuleLoad() { RootPanel panel = RootPanel.get("agencies_map"); if (panel == null) { System.out.println("you didn't include a div with the id of \"agencies_map\""); return;/* ww w. j av a2 s .com*/ } MapWidget map = new MapWidget(); map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); map.addControl(new ScaleControl()); map.setScrollWheelZoomEnabled(true); panel.add(map); StyleInjector.inject(_css.getText()); WebappServiceAsync service = WebappServiceAsync.SERVICE; service.getAgencies(new AgencyHandler(map)); }
From source file:org.sigmah.client.page.entry.editor.MapFieldSet.java
License:Open Source License
private void addMap() { /* Create the map itself */ panel.removeAll();/*ww w . j a va 2 s .co m*/ map = new MapWidget(); panel.add(map); map.addControl(new SmallMapControl()); map.setCenter(LatLng.newInstance(country.getBounds().getCenterY(), country.getBounds().getCenterX())); map.setZoomLevel(6); MapType adminMap = MapTypeFactory.createLocalisationMapType(country); map.addMapType(adminMap); map.setCurrentMapType(adminMap); map.addMapZoomEndHandler(new MapZoomEndHandler() { public void onZoomEnd(MapZoomEndEvent event) { presenter.onMapViewChanged(createBounds(map.getBounds())); } }); map.addMapMoveEndHandler(new MapMoveEndHandler() { @Override public void onMoveEnd(MapMoveEndEvent mapMoveEndEvent) { presenter.onMapViewChanged(createBounds(map.getBounds())); } }); this.addListener(Events.AfterLayout, new Listener<ContainerEvent>() { @Override public void handleEvent(ContainerEvent be) { map.checkResizeAndCenter(); if (pendingZoom != null) { zoomToBounds(pendingZoom); } } }); layout(); }
From source file:org.sigmah.client.page.map.MapPreview.java
License:Open Source License
public void createMapIfNeededAndUpdateMapContent() { if (map == null) { MapApiLoader.load(new MaskingAsyncMonitor(this, I18N.CONSTANTS.loadingMap()), new AsyncCallback<Void>() { @Override/* w ww . jav a 2 s. c o m*/ public void onSuccess(Void result) { apiLoadFailed = false; map = new MapWidget(); map.setDraggable(false); changeBaseMapIfNeeded(content.getBaseMap()); // clear the error message content removeAll(); add(map); updateMapToContent(); } @Override public void onFailure(Throwable caught) { handleApiLoadFailure(); } }); } else { clearOverlays(); changeBaseMapIfNeeded(content.getBaseMap()); updateMapToContent(); } }