List of usage examples for com.google.gwt.maps.client.overlay PolylineOptions newInstance
public static native PolylineOptions newInstance(boolean clickable, boolean geodesic) ;
From source file:com.claudiushauptmann.gwt.maps.gxt.samples.client.OverlayEditor.java
License:Apache License
public void onModuleLoad() { // Map/*from w ww. ja v a2 s. co 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.maps.sample.hellomaps.client.OverlayDemo.java
License:Apache License
private void displayOverlay() { map.clearOverlays();/*from w ww . ja v a2 s . c o 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; } }