List of usage examples for com.google.gwt.maps.client.overlay MarkerOptions setIcon
public final native void setIcon(Icon icon) ;
From source file:com.google.gwt.maps.sample.hellomaps.client.IconClassDemo.java
License:Apache License
/** * Creates a marker whose info window displays the letter corresponding to the * given index.// w w w .j av a 2s. c o m */ private Marker createMarker(LatLng point, int index) { // Create a lettered icon for this point using our icon class final char letter = (char) ('A' + index); Icon icon = Icon.newInstance(baseIcon); icon.setImageURL("http://www.google.com/mapfiles/marker" + letter + ".png"); MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); final Marker marker = new Marker(point, options); marker.addMarkerClickHandler(new MarkerClickHandler() { public void onClick(MarkerClickEvent event) { InfoWindow info = map.getInfoWindow(); info.open(event.getSender(), new InfoWindowContent("Marker <b>" + letter + "</b>")); } }); return marker; }
From source file:com.google.gwt.maps.sample.hellomaps.client.IconDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();/*from w ww . jav a 2 s . c o m*/ // Create our "tiny" marker icon Icon icon = Icon.newInstance("http://labs.google.com/ridefinder/images/mm_20_red.png"); icon.setShadowURL("http://labs.google.com/ridefinder/images/mm_20_shadow.png"); icon.setIconSize(Size.newInstance(12, 20)); icon.setShadowSize(Size.newInstance(22, 20)); icon.setIconAnchor(Point.newInstance(6, 20)); icon.setInfoWindowAnchor(Point.newInstance(5, 1)); // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(new Marker(point, options)); } }
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);//from www .j a v a2s.c om 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.onebusaway.webapp.gwt.oba_application.view.ResultsTablePresenter.java
License:Apache License
private Marker getMarker(int index, LocalSearchResult entry) { ImageResource resource = getMarkerResource(index); Icon icon = Icon.newInstance(resource.getURL()); icon.setIconSize(Size.newInstance(24, 31)); icon.setIconAnchor(Point.newInstance(12, 31)); MarkerOptions opts = MarkerOptions.newInstance(); opts.setClickable(true);/*from w w w .j av a 2 s . c om*/ opts.setIcon(icon); LatLng point = LatLng.newInstance(entry.getLat(), entry.getLon()); return new Marker(point, opts); }
From source file:org.onebusaway.webapp.gwt.where_library.view.stops.TransitMapManager.java
License:Apache License
private Marker getStopMarker(final StopBean stop, final LatLng p, ESize size) { MarkerOptions opts = MarkerOptions.newInstance(); boolean isSelected = false; Icon icon = StopIconFactory.getStopIcon(stop, size, isSelected); opts.setIcon(icon); return new Marker(p, opts); }
From source file:org.opennms.features.poller.remote.gwt.client.GoogleMapsPanel.java
License:Open Source License
private Marker createMarker(final GWTMarkerState marker) { final Icon icon = Icon.newInstance(); icon.setIconSize(Size.newInstance(32, 32)); icon.setIconAnchor(Point.newInstance(16, 32)); String markerImageURL = marker.getImageURL(); icon.setImageURL(markerImageURL);//w ww .j av a 2 s .com final MarkerOptions markerOptions = MarkerOptions.newInstance(); markerOptions.setAutoPan(true); markerOptions.setClickable(true); markerOptions.setTitle(marker.getName()); markerOptions.setIcon(icon); Marker m = new Marker(toLatLng(marker.getLatLng()), markerOptions); m.setVisible(marker.isVisible()); m.addMarkerClickHandler(new DefaultMarkerClickHandler(marker)); return m; }
From source file:org.ow2.aspirerdfid.tracking.demo.client.TrackingDemo.java
License:Open Source License
private Marker createMarker(LatLng point, int index, final TagEventSerialObject tobj) { // Create a lettered icon for this point using our icon class Icon icon = Icon.newInstance(baseIcon); if (index <= 9) { final char digit = (char) ('0' + index); icon.setImageURL("http://google-maps-icons.googlecode.com/files/red" + '0' + digit + ".png"); } else {// ww w . j ava2 s. c o m final char firstDigit = (char) ('0' + index / 10); final char lastDigit = (char) ('0' + index % 10); icon.setImageURL("http://google-maps-icons.googlecode.com/files/red" + firstDigit + lastDigit + ".png"); } MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); final Marker marker = new Marker(point, options); marker.addMarkerClickHandler(new MarkerClickHandler() { public void onClick(MarkerClickEvent event) { InfoWindow info = map.getInfoWindow(); info.open(event.getSender(), new InfoWindowContent("Company Name:" + tobj.getName() + "<br />" + "Description:" + tobj.getDescription() + "<br />" + "Address:" + tobj.getAddress() + "<br />" + "Country:" + tobj.getCountry() + "<br />" + "Region:" + tobj.getRegion() + "<br />" + "Email:" + tobj.getEmail() + "<br />" + "Tel:" + tobj.getTel() + "<br />" + "Fax:" + tobj.getFax())); } }); return marker; }
From source file:org.sigmah.client.page.entry.SiteMap.java
License:Open Source License
public void highlightSite(int siteId, boolean panTo) { Marker marker = sites.get(siteId);/*from ww w . ja v a 2s. co m*/ if (marker != null) { // we can't change the icon ( I don't think ) // so we'll bring in a ringer for the selected site if (highlitMarker == null) { GcIconFactory iconFactory = new GcIconFactory(); iconFactory.primaryColor = "#0000FF"; MarkerOptions opts = MarkerOptions.newInstance(); opts.setIcon(iconFactory.createMarkerIcon()); highlitMarker = new Marker(marker.getLatLng(), opts); map.addOverlay(highlitMarker); } else { // make sure this marker is on top map.removeOverlay(highlitMarker); highlitMarker.setLatLng(marker.getLatLng()); map.addOverlay(highlitMarker); } if (currentHighlightedMarker != null) { currentHighlightedMarker.setVisible(true); } currentHighlightedMarker = marker; currentHighlightedMarker.setVisible(false); if (!map.getBounds().containsLatLng(marker.getLatLng())) { map.panTo(marker.getLatLng()); } } else { // no coords, un highlight existing marker if (currentHighlightedMarker != null) { currentHighlightedMarker.setVisible(true); } if (highlitMarker != null) { map.removeOverlay(highlitMarker); highlitMarker = null; } } }
From source file:org.sigmah.client.page.map.MapPreview.java
License:Open Source License
/** * Updates the size of the map and adds Overlays to reflect the content * of the current/* ww w . j a v a 2s . com*/ */ private void updateMapToContent() { map.setWidth(element.getWidth() + "px"); map.setHeight(element.getHeight() + "px"); Log.debug("MapPreview: Received content, extents are = " + content.getExtents().toString()); zoomToBounds(llBoundsForExtents(content.getExtents())); layout(); map.checkResizeAndCenter(); // TODO: i18n status.setStatus(content.getUnmappedSites().size() + " " + I18N.CONSTANTS.siteLackCoordiantes(), null); GcIconFactory iconFactory = new GcIconFactory(); iconFactory.primaryColor = "#0000FF"; for (MapMarker marker : content.getMarkers()) { Icon icon = IconFactory.createIcon(marker); LatLng latLng = LatLng.newInstance(marker.getLat(), marker.getLng()); MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); Marker overlay = new Marker(latLng, options); map.addOverlay(overlay); overlays.add(overlay); } }
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 . j a v a 2s . c o 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); }