List of usage examples for com.google.gwt.maps.client.geom LatLng newInstance
public static native LatLng newInstance(double latitude, double longitude) ;
From source file:at.ait.dme.yuma.client.map.annotation.GoogleMapsComposite.java
License:EUPL
/** * parse the bounding box into 2 instances of LatLng. * one for the north east and one for the south west. */// w w w .j av a 2s . co m private void parseBoundingBox() { String bBox = Application.getBbox(); if (bBox == null) return; bBox = bBox.replaceAll("[\\[\\]]", ""); String[] coords = bBox.split(","); if (coords.length != 4) return; mapNorthEast = LatLng.newInstance(Double.parseDouble(coords[0]), Double.parseDouble(coords[1])); mapSouthWest = LatLng.newInstance(Double.parseDouble(coords[2]), Double.parseDouble(coords[3])); }
From source file:at.ait.dme.yuma.client.map.annotation.GoogleMapsComposite.java
License:EUPL
/** * transform a point from pixels to LatLng using the provided bounding box * /* ww w . j av a 2 s.c om*/ * @param imageRect * @param xyCoord * @return latlng */ private LatLng transformPoint(ImageAnnotation annotation, XYCoordinate xyCoord) { ImageRect imageRect = annotation.getFragment().getImageRect(); float xRatio = ((float) imageRect.getWidth() / (xyCoord.x - imageRect.getLeft())); float yRatio = ((float) imageRect.getHeight() / (xyCoord.y - imageRect.getTop())); double lat = mapNorthEast.getLatitude() - ((mapNorthEast.getLatitude() - mapSouthWest.getLatitude()) / yRatio); double lng = mapSouthWest.getLongitude() + ((mapNorthEast.getLongitude() - mapSouthWest.getLongitude()) / xRatio); return LatLng.newInstance(lat, lng); }
From source file:at.ait.dme.yuma.client.map.annotation.GoogleMapsComposite.java
License:EUPL
/** * transform a list of points from pixels to LatLng using the transformation service, in case * no bounding box was provided.// w w w. jav a 2s . c o m * * @param xyCoord */ private void transformPoints(List<XYCoordinate> xyCoords) { TransformationServiceAsync transformationService = (TransformationServiceAsync) GWT .create(TransformationService.class); transformationService.transformCoordinates(Application.getExternalObjectId(), Application.getImageUrl(), xyCoords, new AsyncCallback<List<WGS84Coordinate>>() { public void onFailure(Throwable caught) { ErrorMessages errorMessages = (ErrorMessages) GWT.create(ErrorMessages.class); Window.alert(errorMessages.transformationError()); } public void onSuccess(List<WGS84Coordinate> coords) { List<LatLng> latlngCoords = new ArrayList<LatLng>(); for (WGS84Coordinate coord : coords) { latlngCoords.add(LatLng.newInstance(coord.lat, coord.lon)); } // we need to group the coordinates by annotation and display the overlays int fromIndex = 0; for (ImageAnnotation annotation : coordinatesCount.keySet()) { int coordsCount = coordinatesCount.get(annotation); GoogleMapsComposite.this.drawOverlay( new ArrayList<LatLng>( latlngCoords.subList(fromIndex, fromIndex + coordsCount - 1)), annotation); fromIndex += coordsCount; } } }); }
From source file:at.ait.dme.yuma.suite.apps.map.client.widgets.GoogleMapsComposite.java
License:EUPL
/** * transform a list of points from pixels to LatLng using the transformation service, in case * no bounding box was provided./*from w w w .j a va 2s .co m*/ * * @param xyCoord */ private void transformPoints(List<XYCoordinate> xyCoords) { TransformationServiceAsync transformationService = (TransformationServiceAsync) GWT .create(TransformationService.class); transformationService.transformCoordinates(YUMACoreProperties.getObjectURI(), xyCoords, new AsyncCallback<List<WGS84Coordinate>>() { public void onFailure(Throwable caught) { I18NErrorMessages errorMessages = (I18NErrorMessages) GWT.create(I18NErrorMessages.class); Window.alert(errorMessages.transformationError()); } public void onSuccess(List<WGS84Coordinate> coords) { List<LatLng> latlngCoords = new ArrayList<LatLng>(); for (WGS84Coordinate coord : coords) { latlngCoords.add(LatLng.newInstance(coord.lat, coord.lon)); } // we need to group the coordinates by annotation and display the overlays int fromIndex = 0; for (ImageAnnotation annotation : coordinatesCount.keySet()) { int coordsCount = coordinatesCount.get(annotation); GoogleMapsComposite.this.drawOverlay( new ArrayList<LatLng>( latlngCoords.subList(fromIndex, fromIndex + coordsCount - 1)), annotation); fromIndex += coordsCount; } } }); }
From source file:com.claudiushauptmann.gwt.maps.gxt.samples.client.OverlayEditor.java
License:Apache License
public void onModuleLoad() { // Map//from w w w. j a v a 2s . c o m 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 Marker createMarker(final Location loc) { LatLng latlng = LatLng.newInstance(loc.getLatitude(), loc.getLongitude()); final Marker marker = new Marker(latlng); marker.addMarkerClickHandler(new MarkerClickHandler() { public void onClick(MarkerClickEvent event) { final InfoWindow info = map.getInfoWindow(); info.open(marker, newLocationDescription(loc, info, marker)); }//from w w w . j a v a 2 s . co m }); return marker; }
From source file:com.google.gwt.maps.sample.hellomaps.client.AdsManagerDemo.java
License:Apache License
public AdsManagerDemo() { MapOptions mapOptions = MapOptions.newInstance(); mapOptions.setSize(Size.newInstance(500, 600)); // Mountain View LatLng city = LatLng.newInstance(37.4419, -122.1419); map = new MapWidget(city, 13, mapOptions); map.setUIToDefault();//from www . ja v a 2s . c o m AdsManagerOptions adsOptions = AdsManagerOptions.newInstance(); adsOptions.setMaxAdsOnMap(3); adsOptions.setStyle(AdsManagerOptions.STYLE_ADUNIT); String publisherId = "pub-1234567890123456"; // bogus publisher id AdsManager adsManager = AdsManager.newInstance(map, publisherId, adsOptions); adsManager.setEnabled(true); initWidget(map); }
From source file:com.google.gwt.maps.sample.hellomaps.client.ClickDemo.java
License:Apache License
public ClickDemo() { map = new MapWidget(LatLng.newInstance(37.4419, -122.1419), 13); map.setSize("500px", "300px"); initWidget(map);/*from www .ja v a2 s .c o m*/ map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); map.addMapClickHandler(new MapClickHandler() { public void onClick(MapClickEvent e) { MapWidget sender = e.getSender(); Overlay overlay = e.getOverlay(); LatLng point = e.getLatLng(); if (overlay != null && overlay instanceof Marker) { sender.removeOverlay(overlay); } else { sender.addOverlay(new Marker(point)); } } }); }
From source file:com.google.gwt.maps.sample.hellomaps.client.ControlsDemo.java
License:Apache License
public ControlsDemo() { map = new MapWidget(LatLng.newInstance(37.4419, -122.1419), 13); map.setSize("500px", "300px"); initWidget(map);//from ww w . ja v a 2s.c o m map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); Timer timer = new Timer() { @Override public void run() { // Exercise the minimum & maximum resolution entry points. MapType types[] = map.getMapTypes(); for (MapType t : types) { int minResolution = t.getMinimumResolution(); int maxResolution = t.getMaximumResolution(); GWT.log("Map Type: " + t.getName(true) + " Min resolution: " + minResolution + " Max Resolution: " + maxResolution, null); minResolution = t.getMinimumResolution(); maxResolution = t.getMaximumResolution(); GWT.log("@ point: " + map.getCenter().toString() + " Map Type: " + t.getName(true) + " Min resolution: " + minResolution + " Max Resolution: " + maxResolution, null); } } }; timer.schedule(1000); }
From source file:com.google.gwt.maps.sample.hellomaps.client.CustomControlDemo.java
License:Apache License
public CustomControlDemo() { VerticalPanel vertPanel = new VerticalPanel(); vertPanel.setStyleName("hm-panel"); actionListBox = new ListBox(); for (ControlDemos cd : ControlDemos.values()) { actionListBox.addItem(cd.valueOf()); }/*from ww w. j a va2 s . com*/ actionListBox.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { displayCustomControl(); } }); HorizontalPanel horizPanel = new HorizontalPanel(); horizPanel.add(new Label("Choose Action:")); horizPanel.add(actionListBox); horizPanel.setSpacing(10); vertPanel.add(horizPanel); map = new MapWidget(LatLng.newInstance(37.441944, -122.141944), 13); map.setSize("500px", "300px"); map.addMapType(MapType.getNormalMap()); map.addMapType(MapType.getSatelliteMap()); map.addMapType(MapType.getMarsVisibleMap()); map.addMapType(MapType.getMarsElevationMap()); map.addMapType(MapType.getMarsInfraredMap()); vertPanel.add(map); new Timer() { public void run() { displayCustomControl(); } }.schedule(250); initWidget(vertPanel); }