List of usage examples for com.google.gwt.maps.client.geom LatLng getLatitude
public final native double getLatitude() ;
From source file:com.apress.progwt.client.map.MyCollegeMap.java
License:Apache License
private Marker createMarker(final School school) { LatLng point = new LatLng(school.getLatitude(), school.getLongitude()); if (point.getLatitude() == -1 && point.getLongitude() == -1) { return null; }// w w w . j av a 2 s.c om final Marker marker = new Marker(point); marker.addMarkerClickListener(new MarkerClickListener() { public void onClick(Marker sender) { InfoWindow info = map.getInfoWindow(); info.open(sender, new InfoWindowContent(new SchoolLink(school))); } public void onDoubleClick(Marker sender) { } }); return marker; }
From source file:com.apress.progwt.client.util.BulkGeoCoder.java
License:Apache License
@Override public void run() { final HasAddress school = schools.remove(0); if (school == null) { Log.debug("Finished"); cancel();/* w w w . ja va 2 s. co m*/ return; } final String full = school.getFullAddress(); Geocoder geocoder = new Geocoder(); geocoder.getLatLng("1600 pennsylvania avenue, washington dc", new LatLngCallback() { public void onFailure() { } public void onSuccess(LatLng point) { } }); geocoder.getLatLng(full, new LatLngCallback() { public void onFailure() { Log.debug("UPDATE " + tablename + " SET latitude = '-1',longitude = '-1' WHERE id =" + school.getId() + " LIMIT 1 ;"); run(); } public void onSuccess(LatLng point) { Log.debug("UPDATE " + tablename + " SET latitude = '" + point.getLatitude() + "',longitude = '" + point.getLongitude() + "' WHERE id =" + school.getId() + " LIMIT 1 ;"); run(); } }); }
From source file:com.google.gwt.gadgets.sample.traveler.client.TravelMap.java
License:Apache License
private InfoWindowContent newLocationCreateForm(final LatLng point, final LocationHandler handler, final InfoWindow info) { final TextBox titleBox = new TextBox(); final TextArea descriptionBox = new TextArea(); Button saveButton = new Button("Save"); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { titleBox.setReadOnly(true);/* w ww . ja v a 2 s . c om*/ descriptionBox.setReadOnly(true); Location loc = Location.newInstance(); loc.setTitle(titleBox.getText()); loc.setDescription(descriptionBox.getText()); loc.setLatitude(point.getLatitude()); loc.setLongitude(point.getLongitude()); loc.setMilis(Long.toString(new Date().getTime())); handler.handle(loc); info.close(); map.addOverlay(createMarker(loc)); } }); VerticalPanel panel = new VerticalPanel(); panel.add(new HTML("title:")); panel.add(titleBox); panel.add(new HTML("description")); panel.add(descriptionBox); panel.add(saveButton); panel.setCellHorizontalAlignment(saveButton, HasHorizontalAlignment.ALIGN_RIGHT); return new InfoWindowContent(panel); }
From source file:com.google.gwt.maps.sample.hellomaps.client.CustomOverlayDemo.java
License:Apache License
@Override public void onShow() { // The map's bounds are meaningless until the map has been added to the DOM // and sized appropriately if (firstTime) { firstTime = false;//w ww . j ava 2s.c o m LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngDelta = (northEast.getLongitude() - southWest.getLongitude()) / 4; double latDelta = (northEast.getLatitude() - southWest.getLatitude()) / 4; // generate bounds that covers center map with half the width and height LatLngBounds rectBounds = LatLngBounds.newInstance( LatLng.newInstance(southWest.getLatitude() + latDelta, southWest.getLongitude() + lngDelta), LatLng.newInstance(northEast.getLatitude() - latDelta, northEast.getLongitude() - lngDelta)); map.addOverlay(new RectangleOverlay(rectBounds, 2)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.GeocoderDemo.java
License:Apache License
private void displayLatLng(LatLng point) { NumberFormat fmt = NumberFormat.getFormat("#.0000000#"); latLabel.setText(fmt.format(point.getLatitude())); lngLabel.setText(fmt.format(point.getLongitude())); }
From source file:com.google.gwt.maps.sample.hellomaps.client.GroundOverlayDemo.java
License:Apache License
@Override public void onShow() { // The map's bounds are meaningless until the map has been added to the DOM // and sized appropriately if (firstTime) { firstTime = false;/*from w w w . j a v a2 s . c om*/ LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngDelta = (northEast.getLongitude() - southWest.getLongitude()) / 4; double latDelta = (northEast.getLatitude() - southWest.getLatitude()) / 4; // generate bounds that covers center map with half the width and height LatLngBounds rectBounds = LatLngBounds.newInstance( LatLng.newInstance(southWest.getLatitude() + latDelta, southWest.getLongitude() + lngDelta), LatLng.newInstance(northEast.getLatitude() - latDelta, northEast.getLongitude() - lngDelta)); groundOverlay = new GroundOverlay("boot.jpg", rectBounds); groundOverlay.addGroundOverlayVisibilityChangedHandler(new GroundOverlayVisibilityChangedHandler() { public void onVisibilityChanged(GroundOverlayVisibilityChangedEvent event) { if (event.isVisible()) { hideButton.setText("Hide Overlay"); } else { hideButton.setText("Show Overlay"); } } }); map.addOverlay(groundOverlay); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.IconClassDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();/*from w w w . j ava2 s . co m*/ // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(createMarker(point, i)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.IconDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();/*from w w w . ja va2 s. com*/ // Create our "tiny" marker icon Icon icon = Icon.newInstance("http://labs.google.com/ridefinder/images/mm_20_red.png"); icon.setShadowURL("http://labs.google.com/ridefinder/images/mm_20_shadow.png"); icon.setIconSize(Size.newInstance(12, 20)); icon.setShadowSize(Size.newInstance(22, 20)); icon.setIconAnchor(Point.newInstance(6, 20)); icon.setInfoWindowAnchor(Point.newInstance(5, 1)); // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(new Marker(point, options)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
private void computeAtlantaTriangle() { LatLngBounds bounds = map.getBounds(); LatLng center = map.getCenter();// w ww . jav a 2 s . co m LatLng ne = bounds.getNorthEast(); LatLng sw = bounds.getSouthWest(); GWT.log("ne=" + ne + ", sw=" + sw, null); double vertDelta = ne.getLatitude() - sw.getLatitude(); double horizDelta = ne.getLongitude() - sw.getLongitude(); double vertGrid = vertDelta / 4.0; double horizGrid = horizDelta / 8.0; // A triangle pointing north to the west of the center of the map. ATLANTA_TRIANGLE1[0] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() - 2 * horizGrid); ATLANTA_TRIANGLE1[1] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() - 3 * horizGrid); ATLANTA_TRIANGLE1[2] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() - horizGrid); ATLANTA_TRIANGLE1[3] = ATLANTA_TRIANGLE1[0]; GWT.log("1[0] = " + ATLANTA_TRIANGLE1[0], null); GWT.log("1[1] = " + ATLANTA_TRIANGLE1[1], null); GWT.log("1[2] = " + ATLANTA_TRIANGLE1[2], null); GWT.log("1[3] = " + ATLANTA_TRIANGLE1[3], null); // A triangle pointing south to the east of the center of the map. ATLANTA_TRIANGLE2[0] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() + 2 * horizGrid); ATLANTA_TRIANGLE2[1] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() + 3 * horizGrid); ATLANTA_TRIANGLE2[2] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() + horizGrid); ATLANTA_TRIANGLE2[3] = ATLANTA_TRIANGLE2[0]; GWT.log("2[0] = " + ATLANTA_TRIANGLE2[0], null); GWT.log("2[1] = " + ATLANTA_TRIANGLE2[1], null); GWT.log("2[2] = " + ATLANTA_TRIANGLE2[2], null); GWT.log("2[3] = " + ATLANTA_TRIANGLE2[3], null); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MarkerInfoWindowDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();//from w w w.j a v a 2 s . co m // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(createMarker(point, i + 1)); } }