List of usage examples for com.google.gwt.maps.client.overlay Polyline Polyline
protected Polyline(JavaScriptObject jsoPeer)
From source file:com.google.gwt.maps.sample.hellomaps.client.DrawingOverlayDemo.java
License:Apache License
private void createPolyline() { PolyStyleOptions style = PolyStyleOptions.newInstance(color, weight, opacity); final Polyline poly = new Polyline(new LatLng[0]); lastPolyline = poly;//from ww w .j a v a2 s .c o m map.addOverlay(poly); poly.setDrawingEnabled(); poly.setStrokeStyle(style); message2.setText(""); poly.addPolylineLineUpdatedHandler(new PolylineLineUpdatedHandler() { public void onUpdate(PolylineLineUpdatedEvent event) { message2.setText(message2.getText() + " : Line Updated"); } }); poly.addPolylineCancelLineHandler(new PolylineCancelLineHandler() { public void onCancel(PolylineCancelLineEvent event) { message2.setText(message2.getText() + " : Line Canceled"); } }); poly.addPolylineEndLineHandler(new PolylineEndLineHandler() { public void onEnd(PolylineEndLineEvent event) { message2.setText(message2.getText() + " : Line End at " + event.getLatLng() + ". Bounds=" + poly.getBounds().getNorthEast() + "," + poly.getBounds().getSouthWest() + " length=" + poly.getLength() + "m"); } }); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
@Override public void onShow() { map.addOverlay(marker);/* w w w . j a v a 2 s .co m*/ if (firstTime) { computeAtlantaTriangle(); polygon = new Polygon(ATLANTA_TRIANGLE1); polyline = new Polyline(ATLANTA_TRIANGLE2); firstTime = false; } }
From source file:com.google.gwt.maps.sample.hellomaps.client.OverlayDemo.java
License:Apache License
private void displayOverlay() { map.clearOverlays();/*from www . j a v a2 s. co m*/ LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); LatLng[] points = new LatLng[NUM_POINTS]; for (int i = 0; i < NUM_POINTS; i++) { points[i] = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); GWT.log("points[" + i + "] = " + points[i] + " z-index = " + Marker.getZIndex(points[i].getLatitude()), null); } OverlayDemos selected = OverlayDemos.values()[actionListBox.getSelectedIndex()]; switch (selected) { case TEST_TEN_MARKERS: { // Add markers in random locations on the map for (int i = 0; i < NUM_POINTS; i++) { map.addOverlay(new Marker(points[i])); } } break; case TEST_POLYLINE_ONE: { // Add a polyline with NUM_POINTS random points. Sort the points by // longitude so that the line does not intersect itself. Arrays.sort(points, new Comparator<LatLng>() { public int compare(LatLng p1, LatLng p2) { return new Double(p1.getLongitude()).compareTo(new Double(p2.getLongitude())); } }); Polyline pline = new Polyline(points); map.addOverlay(pline); if (pline.getVertexCount() != NUM_POINTS) { Window.alert("Created polyline with " + NUM_POINTS + " vertices, but now it has " + pline.getVertexCount()); } } break; case TEST_POLYLINE_ENCODED: { // Add a polyline encoded in a string map.setCenter(LatLng.newInstance(40.71213418976525, -73.96785736083984), 15); Polyline pline = Polyline.fromEncoded("#3333cc", 10, 1.0, ENCODED_POINTS, 32, ENCODED_LEVELS, 4); map.addOverlay(pline); } break; case TEST_POLYLINE_GEODESIC: { LatLng nycToZurich[] = { LatLng.newInstance(40.75, -73.90), // New York LatLng.newInstance(47.3, 8.5) // Zurich }; map.setCenter(LatLng.newInstance(40, -25), 2); Polyline pline = new Polyline(nycToZurich, "#FF0000", 1, .75, PolylineOptions.newInstance(false, true)); map.addOverlay(pline); } break; case TEST_POLYLINE_ENCODED_TRANSPARENT: { // Add a polyline with transparency map.setCenter(LatLng.newInstance(40.71213418976525, -73.96785736083984), 15); Polyline pline = Polyline.fromEncoded(ENCODED_POINTS, 32, ENCODED_LEVELS, 4); map.addOverlay(pline); } break; case TEST_POLYGON_ENCODED: { // Add a polygon encoded as a series of polylines. map.setCenter(LatLng.newInstance(33.75951619957536, -84.39289301633835), 20); EncodedPolyline[] polylines = new EncodedPolyline[2]; polylines[0] = EncodedPolyline.newInstance("au`mEz_bbO?sAbA@?pAcA?", 2, "BBBBB", 1, "#ff0000", 2, 0.9); polylines[1] = EncodedPolyline.newInstance("{t`mEt_bbO?eAx@??dAy@?", 2, "BBBBB", 1); polylines[1].setColor("#ff0000"); polylines[1].setWeight(2); polylines[1].setOpacity(0.7); Polygon theFountain = Polygon.fromEncoded(polylines, true, "#ff0000", 0.2, true); map.addOverlay(theFountain); map.setCurrentMapType(MapType.getHybridMap()); } break; default: Window.alert("Cannot handle selection: " + selected.valueOf()); break; } }
From source file:org.onebusaway.webapp.gwt.oba_application.control.MinTransitTimeResultHandler.java
License:Apache License
private void showSearchGrid(MinTransitTimeResult result) { for (final CoordinateBounds lb : result.getSearchGrid()) { LatLng a = LatLng.newInstance(lb.getMinLat(), lb.getMinLon()); LatLng b = LatLng.newInstance(lb.getMaxLat(), lb.getMinLon()); LatLng c = LatLng.newInstance(lb.getMaxLat(), lb.getMaxLon()); LatLng d = LatLng.newInstance(lb.getMinLat(), lb.getMaxLon()); LatLng[] points = { a, b, c, d, a }; Polyline line = new Polyline(points); _mapManager.addOverlay(line, 10, 20); Marker marker = new Marker(b); marker.addMarkerClickHandler(new MarkerClickHandler() { public void onClick(MarkerClickEvent event) { System.out.println(lb.getMinLat() + " " + lb.getMinLon()); System.out.println(lb.getMaxLat() + " " + lb.getMaxLon()); }/*www . j av a 2 s. c om*/ }); _mapManager.addOverlay(marker, 10, 20); } }
From source file:org.ow2.aspirerdfid.tracking.demo.client.TrackingDemo.java
License:Open Source License
protected void processData(List<TagEventSerialObject> result) { if (result.isEmpty()) return;//from w w w.j a v a 2s. com // Clear previous markers etc map.clearOverlays(); // Get the underlying list from data dataProvider. List<TagDataPoint> taglist = dataProvider.getList(); taglist.clear(); int count = 0; LatLng[] polypoint = new LatLng[result.size()]; for (TagEventSerialObject tagESObj : result) { // Add even to list taglist.add(new TagDataPoint(tagESObj.getTag(), DateTimeFormat.getFormat("dd.MM.yyyy G '@' HH:mm:ss vvvv").format(tagESObj.getTimeDate()), tagESObj.getGeoTag(), count, tagESObj.getEpcClassProperties())); count++; String[] temp; /* Add markers on the map */ String delimiter = ":"; temp = tagESObj.getGeoTag().split(delimiter); polypoint[count - 1] = LatLng.newInstance(Double.parseDouble(temp[0]), Double.parseDouble(temp[1])); ; map.addOverlay(createMarker(polypoint[count - 1], count, tagESObj)); } PolyStyleOptions style = PolyStyleOptions.newInstance(color, weight, opacity); final Polyline poly = new Polyline(polypoint); poly.setStrokeStyle(style); map.addOverlay(poly); }