List of usage examples for com.google.gwt.maps.client.overlay Polyline setStrokeStyle
public void setStrokeStyle(PolyStyleOptions style)
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;// w w w . j a v a2s .c om 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:org.onebusaway.webapp.gwt.tripplanner_library.view.TripBeanMapPresenter.java
License:Apache License
public void displayTrip(ItineraryBean trip, List<Overlay> resultingOverlays) { resultingOverlays.clear();//from w w w . j a va 2s.c om LatLngBounds bounds = LatLngBounds.newInstance(); for (LegBean segment : trip.getLegs()) { String mode = segment.getMode(); if (mode.equals("transit")) { TransitLegBean leg = segment.getTransitLeg(); String path = leg.getPath(); if (path != null) { List<CoordinatePoint> points = PolylineEncoder.decode(path); EncodedPolylineBean bean = PolylineEncoder.createEncodings(points); Polyline line = getPathAsPolyline(bean); PolyStyleOptions style = PolyStyleOptions.newInstance("#0000FF", 4, 0.5); line.setStrokeStyle(style); resultingOverlays.add(line); addBoundsToBounds(line.getBounds(), bounds); } StopBean stop = leg.getFromStop(); if (stop != null) { String routeName = leg.getRouteShortName(); TripPlannerResources resources = TripPlannerResources.INSTANCE; SpanPanel w = new SpanPanel(); w.addStyleName(_css.routeTinyInfoWindow()); Image image = new Image(resources.getBus14x14().getUrl()); image.addStyleName(_css.routeModeIcon()); w.add(image); SpanWidget name = new SpanWidget(routeName); name.setStyleName(_css.routeName()); w.add(name); LatLng point = LatLng.newInstance(stop.getLat(), stop.getLon()); TinyInfoWindowMarker marker = new TinyInfoWindowMarker(point, w); resultingOverlays.add(marker); bounds.extend(point); } } else if (mode.equals("walk")) { List<StreetLegBean> streetLegs = segment.getStreetLegs(); List<CoordinatePoint> allPoints = new ArrayList<CoordinatePoint>(); for (StreetLegBean streetLeg : streetLegs) { String path = streetLeg.getPath(); List<CoordinatePoint> points = PolylineEncoder.decode(path); allPoints.addAll(points); } EncodedPolylineBean polyline = PolylineEncoder.createEncodings(allPoints); Polyline line = getPathAsPolyline(polyline); PolyStyleOptions style = PolyStyleOptions.newInstance("#000000", 4, 0.8); line.setStrokeStyle(style); resultingOverlays.add(line); addBoundsToBounds(line.getBounds(), bounds); } } for (Overlay overlay : resultingOverlays) _map.addOverlay(overlay); if (_centerOnTrip && !bounds.isEmpty()) { _map.setCenter(bounds.getCenter()); int zoom = _map.getBoundsZoomLevel(bounds); _map.setCenter(bounds.getCenter(), zoom); } }
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 ww .ja v a2 s .c o m // 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); }