List of usage examples for com.google.gwt.maps.client.overlay Icon newInstance
public static native Icon newInstance(String imageUrl) ;
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 ww.j a v a2 s . c om */ 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();/*w ww . j a v a 2 s .c om*/ // 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 w w w . ja va 2s .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.ActiveResultPresenter.java
License:Apache License
private Icon getStar30Marker() { OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE; ImageResource r = resources.getStar30(); Icon icon = Icon.newInstance(r.getURL()); icon.setIconSize(Size.newInstance(30, 28)); icon.setIconAnchor(Point.newInstance(15, 14)); return icon;//from www .ja v a2s . co m }
From source file:org.onebusaway.webapp.gwt.oba_application.view.ActiveResultPresenter.java
License:Apache License
private Icon getStar20Marker() { OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE; ImageResource r = resources.getStar20(); Icon icon = Icon.newInstance(r.getURL()); icon.setIconSize(Size.newInstance(20, 19)); icon.setIconAnchor(Point.newInstance(10, 10)); return icon;/*from w w w. j av a2s .c o m*/ }
From source file:org.onebusaway.webapp.gwt.oba_application.view.ActiveResultPresenter.java
License:Apache License
private Icon getStar15Marker() { OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE; ImageResource r = resources.getStar15(); Icon icon = Icon.newInstance(r.getURL()); icon.setIconSize(Size.newInstance(15, 14)); icon.setIconAnchor(Point.newInstance(8, 7)); return icon;//from w ww.j a va 2 s . c o m }
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 a v a 2s . c o m*/ opts.setIcon(icon); LatLng point = LatLng.newInstance(entry.getLat(), entry.getLon()); return new Marker(point, opts); }
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 {/*from w w w .j ava 2 s . co 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.map.GcIconFactory.java
License:Open Source License
/** * Creates an icon based on the specified options * Supported options are: width, height, primaryColor, * strokeColor, and cornerColor./*from w w w. j ava 2 s . c o m*/ * * @return Icon for GoogleMaps */ public Icon createMarkerIcon() { String baseUrl = "http://chart.apis.google.com/chart?cht=mm"; String iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + cornerColor.replace("#", "") + "," + primaryColor.replace("#", "") + "," + strokeColor.replace("#", "") + "&ext=.png"; Icon icon = Icon.newInstance(iconUrl); icon.setIconSize(Size.newInstance(width, height)); icon.setShadowSize(Size.newInstance((int) Math.floor(width * 1.6), height)); icon.setIconAnchor(Point.newInstance(width / 2, height)); icon.setInfoWindowAnchor(Point.newInstance(width / 2, (int) Math.floor(height / 12))); icon.setPrintImageURL(iconUrl + "&chof=gif"); icon.setMozPrintImageURL(iconUrl + "&chf=bg,s,ECECD8" + "&chof=gif"); iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + cornerColor.replace("#", "") + "," + primaryColor.replace("#", "") + "," + strokeColor.replace("#", ""); icon.setTransparentImageURL(iconUrl + "&chf=a,s,ffffff11&ext=.png"); icon.setImageMap(new int[] { width / 2, height, (int) ((7d / 16d) * width), (int) ((5d / 8d) * height), (int) ((5d / 16d) * width), (int) ((7d / 16d) * height), (int) ((7d / 32d) * width), (int) ((5d / 16d) * height), (int) ((5d / 16d) * width), (int) ((1d / 8d) * height), (int) ((1d / 2d) * width), 0, (int) ((11d / 16d) * width), (int) ((1d / 8d) * height), (int) ((25d / 32d) * width), (int) ((5d / 16d) * height), (int) ((11d / 16d) * width), (int) ((7d / 16d) * height), (int) ((9d / 16d) * width), (int) ((5d / 8d) * height) }); return icon; }
From source file:org.sigmah.client.map.GcIconFactory.java
License:Open Source License
/** * Creates a flat icon based on the specified options * Supported options are: width, height, primaryColor, * shadowColor, label, labelColor, labelSize, and shape.. * * @return Icon object for use in GoogleMaps */// w w w .j a v a 2 s . co m public Icon createFlatIcon() { String shapeCode = ("circle".equals(shape)) ? "it" : "itr"; String baseUrl = "http://chart.apis.google.com/chart?cht=" + shapeCode; String iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + primaryColor.replace("#", "") + "," + shadowColor.replace("#", "") + "ff,ffffff01" + "&chl=" + label + "&chx=" + labelColor.replace("#", "") + "," + labelSize; Icon icon = Icon.newInstance(Icon.DEFAULT_ICON); icon.setImageURL(iconUrl + "&chf=bg,s,00000000" + "&ext=.png"); icon.setIconSize(Size.newInstance(width, height)); icon.setShadowSize(Size.newInstance(0, 0)); icon.setIconAnchor(Point.newInstance(width / 2, height / 2)); icon.setInfoWindowAnchor(Point.newInstance(width / 2, height / 2)); icon.setPrintImageURL(iconUrl + "&chof=gif"); icon.setMozPrintImageURL(iconUrl + "&chf=bg,s,ECECD8" + "&chof=gif"); icon.setTransparentImageURL(iconUrl + "&chf=a,s,ffffff01&ext=.png"); if (shapeCode.equals("itr")) { icon.setImageMap(new int[] { 0, 0, width, 0, width, height, 0, height }); } else { icon.setImageMap(createCircleImageMap(width, height, 8)); } return icon; }