List of usage examples for com.google.gwt.maps.client.overlays MarkerOptions setIcon
public final native void setIcon(MarkerImage icon) ;
From source file:com.arcbees.website.client.application.contact.ContactView.java
License:Apache License
private void onMapsLoaded() { // -- HOW TO STYLE A GOOGLE MAP // -> First, we create the style. To help : http://software.stadtwerk.org/google_maps_colorizr/ MapTypeStyle style1 = MapTypeStyle.newInstance(); style1.setElementType(MapTypeStyleElementType.GEOMETRY); style1.setFeatureType(MapTypeStyleFeatureType.ROAD); style1.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#FFF"), MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(100) }); MapTypeStyle style2 = MapTypeStyle.newInstance(); style2.setElementType(MapTypeStyleElementType.ALL); style2.setFeatureType(MapTypeStyleFeatureType.LANDSCAPE); style2.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#cccccc"), MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(-10) }); MapTypeStyle style3 = MapTypeStyle.newInstance(); style3.setElementType(MapTypeStyleElementType.ALL); style3.setFeatureType(MapTypeStyleFeatureType.POI); style3.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#f00"), MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(9), }); MapTypeStyle style4 = MapTypeStyle.newInstance(); style4.setElementType(MapTypeStyleElementType.ALL); style4.setFeatureType(MapTypeStyleFeatureType.WATER); style4.setStylers(new MapTypeStyler[] { MapTypeStyler.newHueStyler("#1c1c1c"), MapTypeStyler.newSaturationStyler(-100), MapTypeStyler.newLightnessStyler(86), }); MapTypeStyle[] array = { style1, style2, style3, style4 }; JsArray<MapTypeStyle> styles = ArrayHelper.toJsArray(array); // -> Then we tell the map to use our new style by default MapTypeControlOptions controlOptions = MapTypeControlOptions.newInstance(); controlOptions.setMapTypeIds(new String[] {}); controlOptions.setPosition(ControlPosition.TOP_RIGHT); // -> And tell the map what our custom style is StyledMapTypeOptions styledMapTypeOptions = StyledMapTypeOptions.newInstance(); styledMapTypeOptions.setName("Arcbees"); StyledMapType customMapType = StyledMapType.newInstance(styles, styledMapTypeOptions); // -> Then we define our Lat and Long LatLng arcbeesCoord = LatLng.newInstance(46.792097, -71.285362); // -> Then goes the map options MapOptions options = MapOptions.newInstance(); options.setCenter(arcbeesCoord);/*from ww w . j a v a2s. co m*/ options.setZoom(16); options.setScrollWheel(false); options.setMapTypeControlOptions(controlOptions); options.setMapTypeId(ARCBEES_MAPTYPE); options.setPanControl(false); options.setDraggable(Window.getClientWidth() > 649); ZoomControlOptions zoomControlOptions = ZoomControlOptions.newInstance(); zoomControlOptions.setPosition(ControlPosition.RIGHT_CENTER); options.setZoomControlOptions(zoomControlOptions); // -> We create the map with our options MapWidget mapWidget = new MapWidget(options); mapWidget.addStyleName(page.style().map()); mapWidget.setCustomMapType(ARCBEES_MAPTYPE, customMapType); // -> We define the marker MarkerOptions markerOptions = MarkerOptions.newInstance(); markerOptions.setIcon(pageContactResources.marker().getSafeUri().asString()); markerOptions.setMap(mapWidget); markerOptions.setPosition(arcbeesCoord); Marker.newInstance(markerOptions); // -> And finally, add it to its container container.add(mapWidget); }
From source file:gov.nist.spectrumbrowser.client.SensorGroupMarker.java
License:Open Source License
private SensorGroupMarker(double lat, double lon) { this.lat = lat; this.lon = lon; this.position = LatLng.newInstance(lat, lon); String iconPath = SpectrumBrowser.getIconsPath() + "mm_20_red.png"; logger.finer("lon = " + lon + " lat = " + lat + " iconPath = " + iconPath); MarkerImage notSelectedIcon = MarkerImage.newInstance(iconPath); notSelectedIcon.setSize(Size.newInstance(12, 20)); notSelectedIcon.setAnchor(Point.newInstance(6, 20)); MarkerOptions notSelectedMarkerOptions = MarkerOptions.newInstance(); notSelectedMarkerOptions.setIcon(notSelectedIcon); notSelectedMarkerOptions.setClickable(true); notSelectedMarker = Marker.newInstance(notSelectedMarkerOptions); // Attach marker to the map. notSelectedMarker.addMouseOverHandler(new NotSelectedMarkerMouseOverMapHandler()); notSelectedMarker.addMouseOutMoveHandler(new NotSelectedMarkerMouseOutMapHandler()); notSelectedMarker.addMouseDownHandler(new NotSelectedMarkerMouseDownMapHandler()); notSelectedMarker.setPosition(position); notSelectedMarker.setVisible(true);//from w w w.j a v a2 s. c om notSelectedMarker.setZindex(1); // Create icons for the selected marker. iconPath = SpectrumBrowser.getIconsPath() + "mm_20_yellow.png"; MarkerImage selectedIcon = MarkerImage.newInstance(iconPath); selectedIcon.setSize(Size.newInstance(12, 20)); selectedIcon.setAnchor(Point.newInstance(6, 20)); // create marker options for the selected maker. MarkerOptions selectedMarkerOptions = MarkerOptions.newInstance(); selectedMarkerOptions.setIcon(iconPath); selectedMarkerOptions.setClickable(true); // Create and attach the selected marker. selectedMarker = Marker.newInstance(selectedMarkerOptions); selectedMarker.setPosition(position); selectedMarker.setVisible(true); selectedMarker.setZindex(0); }
From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java
License:Open Source License
@Override public void addMapMarker(Position position) { if (myLocationMarker != null) { myLocationMarker.setMap((MapWidget) null); }//from w w w . j av a 2s. c o m if (myLocationError != null) { myLocationError.setMap(null); } LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(), position.getCoordinates().getLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(center); MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString()); icon.setAnchor(Point.newInstance(11, 11)); options.setOptimized(true); options.setIcon(icon); myLocationMarker = Marker.newInstance(options); myLocationMarker.setMap(mapWidget); // create a circle the size of the error CircleOptions circleOptions = CircleOptions.newInstance(); circleOptions.setFillOpacity(0.1); circleOptions.setFillColor("#1a75ff"); circleOptions.setStrokeOpacity(0.12); circleOptions.setStrokeWeight(1); circleOptions.setStrokeColor("#1a75ff"); myLocationError = Circle.newInstance(circleOptions); myLocationError.setCenter(center); myLocationError.setRadius(position.getCoordinates().getAccuracy()); myLocationError.setMap(mapWidget); }
From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java
License:Open Source License
@Override public void drawCameras(final List<CameraItem> cameras) { deleteCameras();/*from w ww . jav a 2s .c o m*/ for (final CameraItem camera : cameras) { final LatLng loc = LatLng.newInstance(camera.getLatitude(), camera.getLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); MarkerImage icon; if (camera.getHasVideo() == 1) { icon = MarkerImage.newInstance(AppBundle.INSTANCE.cameraVideoPNG().getSafeUri().asString()); } else { icon = MarkerImage.newInstance(AppBundle.INSTANCE.cameraPNG().getSafeUri().asString()); } options.setIcon(icon); cameraMarker = Marker.newInstance(options); cameraMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onCameraSelected(camera.getCameraId()); } }); cameraMarkers.add(cameraMarker); } if (Boolean.valueOf(localStorage.getItem("KEY_SHOW_CAMERAS"))) { showCameras(); } }
From source file:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java
License:Open Source License
@Override public void drawFerries(List<VesselWatchItem> vessels) { deleteFerries();/* w w w .j av a 2 s .c om*/ for (final VesselWatchItem vessel : vessels) { final LatLng loc = LatLng.newInstance(vessel.getLat(), vessel.getLon()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); MarkerImage icon = MarkerImage.newInstance(vessel.getIcon()); options.setIcon(icon); MarkerImage shadow = MarkerImage.newInstance(vessel.getIconShadow()); options.setShadow(shadow); vesselMarker = Marker.newInstance(options); vesselMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onFerrySelected(vessel); } }); vesselMarkers.add(vesselMarker); } showFerries(); }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
@Override public void drawCameras(final List<CameraItem> cameras) { deleteCameras();//from ww w . j a va 2 s. co m for (final CameraItem camera : cameras) { final LatLng loc = LatLng.newInstance(camera.getLatitude(), camera.getLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); MarkerImage icon; if (camera.getHasVideo() == 1) { icon = MarkerImage.newInstance(AppBundle.INSTANCE.cameraVideoPNG().getSafeUri().asString()); } else { icon = MarkerImage.newInstance(AppBundle.INSTANCE.cameraPNG().getSafeUri().asString()); } options.setIcon(icon); cameraMarker = Marker.newInstance(options); cameraMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onCameraSelected(camera.getCameraId()); } }); cameraMarkers.add(cameraMarker); } if (Boolean.valueOf(localStorage.getItem("KEY_SHOW_CAMERAS"))) { showCameras(); } }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
@Override public void drawAlerts(List<HighwayAlertItem> alerts) { // Types of categories which result in one icon or another being displayed. String[] eventClosure = { "closed", "closure" }; String[] eventConstruction = { "construction", "maintenance", "lane closure" }; HashMap<String, String[]> eventCategories = new HashMap<String, String[]>(); eventCategories.put("closure", eventClosure); eventCategories.put("construction", eventConstruction); deleteAlerts();/*from w w w . j a v a 2 s. c o m*/ for (final HighwayAlertItem alert : alerts) { LatLng loc = LatLng.newInstance(alert.getStartLatitude(), alert.getStartLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); // Determine correct icon for alert type ImageResource imageResource = getCategoryIcon(eventCategories, alert.getEventCategory(), alert.getPriority()); MarkerImage icon = MarkerImage.newInstance(imageResource.getSafeUri().asString()); options.setIcon(icon); alertMarker = Marker.newInstance(options); alertMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onAlertSelected(alert.getAlertId()); } }); alertMarkers.add(alertMarker); } showAlerts(); }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
@Override public void drawRestAreas(List<RestAreaItem> restAreas) { ImageResource noDumpSiteIcon = AppBundle.INSTANCE.restAreaPNG(); ImageResource dumpSiteIcon = AppBundle.INSTANCE.restAreaDumpPNG(); deleteRestAreas();/* w w w . j ava 2 s. c om*/ for (final RestAreaItem restArea : restAreas) { LatLng loc = LatLng.newInstance(Double.valueOf(restArea.getLatitude()), Double.valueOf(restArea.getLongitude())); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); // Determine correct icon for restarea type ImageResource imageResource = restArea.hasDump() ? dumpSiteIcon : noDumpSiteIcon; MarkerImage icon = MarkerImage.newInstance(imageResource.getSafeUri().asString()); options.setIcon(icon); restAreaMarker = Marker.newInstance(options); restAreaMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onRestAreaSelected(restArea.getId()); } }); restAreaMarkers.add(restAreaMarker); } if (Boolean.valueOf(localStorage.getItem("KEY_SHOW_RESTAREAS"))) { showRestAreas(); } }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
@Override public void drawCallouts(List<CalloutItem> callouts) { deleteCallouts();//from w w w . j a v a 2s . c om for (final CalloutItem callout : callouts) { LatLng loc = LatLng.newInstance(callout.getLatitude(), callout.getLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(loc); MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.jblmPNG().getSafeUri().asString()); options.setIcon(icon); calloutMarker = Marker.newInstance(options); calloutMarker.addClickHandler(new ClickMapHandler() { @Override public void onEvent(ClickMapEvent event) { presenter.onCalloutSelected(callout.getImageUrl()); } }); calloutMarkers.add(calloutMarker); } showCallouts(); }
From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java
License:Open Source License
@Override public void addMapMarker(Position position) { if (myLocationMarker != null) { myLocationMarker.setMap((MapWidget) null); }/* www . ja v a2 s .com*/ if (myLocationError != null) { myLocationError.setMap(null); } LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(), position.getCoordinates().getLongitude()); MarkerOptions options = MarkerOptions.newInstance(); options.setPosition(center); MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString()); icon.setAnchor(Point.newInstance(11, 11)); options.setOptimized(true); options.setIcon(icon); myLocationMarker = Marker.newInstance(options); myLocationMarker.setMap(mapWidget); // create a circle the size of the error CircleOptions circleOptions = CircleOptions.newInstance(); circleOptions.setFillOpacity(0.1); circleOptions.setFillColor("#1a75ff"); circleOptions.setStrokeOpacity(0.12); circleOptions.setStrokeWeight(1); circleOptions.setStrokeColor("#1a75ff"); myLocationError = Circle.newInstance(circleOptions); myLocationError.setCenter(center); myLocationError.setRadius(position.getCoordinates().getAccuracy()); myLocationError.setMap(mapWidget); }