List of usage examples for com.google.gwt.maps.client.overlay MarkerOptions setDraggable
public final native void setDraggable(boolean draggable) ;
From source file:com.claudiushauptmann.gwt.maps.gxt.samples.client.OverlayEditor.java
License:Apache License
public void onModuleLoad() { // Map//from w w w. j a va2 s . c om 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.DragMarkerDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();/*from w w w .ja v a 2 s . c om*/ MarkerOptions options = MarkerOptions.newInstance(); options.setDraggable(true); final Marker marker = new Marker(map.getCenter(), options); final InfoWindow info = map.getInfoWindow(); marker.addMarkerDragEndHandler(new MarkerDragEndHandler() { public void onDragEnd(MarkerDragEndEvent event) { info.open(marker, new InfoWindowContent("Just bouncing along...")); } }); marker.addMarkerDragStartHandler(new MarkerDragStartHandler() { public void onDragStart(MarkerDragStartEvent event) { info.setVisible(false); } }); map.addOverlay(marker); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
public MapEventDemo() { VerticalPanel vp = new VerticalPanel(); // Center the new map on Midtown Atlanta map = new MapWidget(ATLANTA, 13); map.setSize("500px", "300px"); map.addControl(new SmallMapControl()); map.addControl(new MapTypeControl()); MarkerOptions opt = MarkerOptions.newInstance(); opt.setDraggable(true); marker = new Marker(ATLANTA, opt); Panel hp1 = createActionButtons(); HorizontalPanel hp2 = createListenerListBox(); // Make a spacer HorizontalPanel hp3 = new HorizontalPanel(); hp3.add(new Label(" ")); hp3.setSize("1em", "1em"); handlerTable = new FlexTable(); clearListenerTable();/* w w w . j av a 2 s. c o m*/ vp.add(map); vp.add(hp1); vp.add(hp2); vp.add(hp3); vp.add(handlerTable); initWidget(vp); }
From source file:org.maps.client.TRIFacilitiesLayer.java
License:Apache License
@Override protected void refreshMarkers(LatLngBounds bounds, final IRefreshMarkersCallback callback) { if (getMap().getZoomLevel() < getStartZoomLevel()) { List<Marker> newMarkers = new ArrayList<Marker>(); callback.onRefresh(newMarkers);// www . j av a2s . co m return; } setCurrentZoomLevel(getMap().getZoomLevel()); AsyncCallback<List<ITRIFacility>> serviceCallback = new AsyncCallback<List<ITRIFacility>>() { public void onFailure(Throwable caught) { callback.onError(caught); } public void onSuccess(List<ITRIFacility> result) { for (ITRIFacility facility : result) { MarkerOptions options = MarkerOptions.newInstance(); options.setTitle(facility.getFacilityName()); if (facility.getNumberOfFacilities() > 1) { String url = "images/cluster.png"; Icon icon = Icon.newInstance(url); options.setIcon(icon); } options.setDraggable(false); LatLng location = LatLng.newInstance(facility.getLatitude(), facility.getLongitude()); Marker marker = new Marker(location, options); if (facility.getNumberOfFacilities() > 1) { marker.addMarkerClickHandler(getClusterClickHandler()); } else { marker.addMarkerClickHandler(getFacilityClickHandler()); } register(marker, facility); } callback.onRefresh(getMarkers()); } }; double swLat = bounds.getSouthWest().getLatitude(); double swLng = bounds.getSouthWest().getLongitude(); double neLat = bounds.getNorthEast().getLatitude(); double neLng = bounds.getNorthEast().getLongitude(); service.get(swLat, swLng, neLat, neLng, serviceCallback); }
From source file:org.sigmah.client.page.entry.editor.MapFieldSet.java
License:Open Source License
private void createMarker(LatLng latlng) { MarkerOptions options = MarkerOptions.newInstance(); options.setDraggable(true); marker = new Marker(latlng, options); marker.addMarkerDragEndHandler(new MarkerDragEndHandler() { public void onDragEnd(MarkerDragEndEvent event) { LatLng latlng = marker.getLatLng(); presenter.onMarkerMoved(latlng.getLatitude(), latlng.getLongitude()); }// ww w .ja va 2s. c o m }); map.addOverlay(marker); }
From source file:org.sigmah.client.ui.widget.map.GoogleWorldMap.java
License:Open Source License
@Override protected Marker createNativePin(Pin pin) { final MarkerOptions options = MarkerOptions.newInstance(); if (pin.getTitle() != null) { options.setTitle(pin.getTitle()); }// w w w. ja v a 2 s. co m options.setDraggable(pin.isDraggable()); if (pin.getImageURL() != null) { final Icon icon = Icon.newInstance(pin.getImageURL()); icon.setIconSize(Size.newInstance(pin.getImageWidth(), pin.getImageHeight())); icon.setIconAnchor(Point.newInstance( // Horizontal center pin.getImageWidth() / 2, // Bottom pin.getImageHeight())); options.setIcon(icon); } return new Marker(LatLng.newInstance(pin.getLatitude(), pin.getLongitude()), options); }