List of usage examples for com.google.gwt.maps.client.overlay Polygon Polygon
public Polygon(LatLng[] points, String strokeColor, int strokeWeight, double strokeOpacity, String fillColor, double fillOpacity)
From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java
License:Apache License
private void createPolygon() { PolyStyleOptions style = PolyStyleOptions.newInstance(color, weight, opacity); final Polygon poly = new Polygon(new LatLng[0], color, weight, opacity, color, fillFlag ? .7 : 0.0); lastPolygon = poly;/* ww w .ja v a 2 s.co m*/ map.addOverlay(poly); poly.setDrawingEnabled(); poly.setStrokeStyle(style); message2.setText(""); poly.addPolygonLineUpdatedHandler(new PolygonLineUpdatedHandler() { public void onUpdate(PolygonLineUpdatedEvent event) { message2.setText(message2.getText() + " : Polygon Updated"); } }); poly.addPolygonCancelLineHandler(new PolygonCancelLineHandler() { public void onCancel(PolygonCancelLineEvent event) { message2.setText(message2.getText() + " : Polygon Cancelled"); } }); poly.addPolygonEndLineHandler(new PolygonEndLineHandler() { public void onEnd(PolygonEndLineEvent event) { message2.setText(message2.getText() + " : Polygon End at " + event.getLatLng() + ". Bounds=" + poly.getBounds().getNorthEast() + "," + poly.getBounds().getSouthWest() + " area=" + poly.getArea() + "m"); } }); }
From source file:com.google.gwt.maps.sample.hellomaps.client.StreetviewDemo.java
License:Apache License
private void updatePolyline() { if (viewPolygon != null) { map.removeOverlay(viewPolygon);/*from ww w . java 2s. c om*/ } // Some simple math to calculate viewPolygon double yaw = currentPov.getYaw(); double distanceFactor = Math.cos(Math.toRadians(currentPov.getPitch())) * 0.0015 + 0.0005; double zoomFactor = currentPov.getZoom() * 0.7 + 1; LatLng[] points = new LatLng[11]; points[0] = points[10] = currentLatLng; for (int i = 1; i < 10; i++) { double angle = Math.toRadians(yaw + (i - 5) * 7d / zoomFactor); points[i] = LatLng.newInstance(currentLatLng.getLatitude() + Math.cos(angle) * distanceFactor, currentLatLng.getLongitude() + Math.sin(angle) * distanceFactor); } viewPolygon = new Polygon(points, "blue", 1, 0.5, "blue", 0.15); map.addOverlay(viewPolygon); }
From source file:es.upm.fi.dia.oeg.map4rdf.client.widget.mapcontrol.StatisticsMapControl.java
License:Open Source License
private void drawCircleFromRadius(LatLng center, double radius, int nbOfPoints) { LatLngBounds bounds = LatLngBounds.newInstance(); LatLng[] circlePoints = new LatLng[nbOfPoints]; double EARTH_RADIUS = 6371000; double d = radius / EARTH_RADIUS; double lat1 = Math.toRadians(center.getLatitude()); double lng1 = Math.toRadians(center.getLongitude()); double a = 0; double step = 360.0 / nbOfPoints; for (int i = 0; i < nbOfPoints; i++) { double tc = Math.toRadians(a); double lat2 = Math.asin(Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(tc)); double lng2 = lng1 + Math.atan2(Math.sin(tc) * Math.sin(d) * Math.cos(lat1), Math.cos(d) - Math.sin(lat1) * Math.sin(lat2)); LatLng point = LatLng.newInstance(Math.toDegrees(lat2), Math.toDegrees(lng2)); circlePoints[i] = point;/*from www . j a va 2s . c om*/ bounds.extend(point); a += step; } Polygon circle = new Polygon(circlePoints, "white", 0, 0, "green", 0.4); addOverlay(circle); }