Search in sources :

Example 1 with MarkerOptions

use of org.discotools.gwt.leaflet.client.marker.MarkerOptions in project activityinfo by bedatadriven.

the class LeafletMarkerFactory method createPieMapMarker.

public static Marker createPieMapMarker(PieMapMarker marker) {
    StringBuilder sb = new StringBuilder();
    sb.append("/icon?t=piechart&r=").append(marker.getRadius());
    for (SliceValue slice : marker.getSlices()) {
        sb.append("&value=").append(slice.getValue());
        sb.append("&color=").append(slice.getColor());
    }
    String iconUrl = sb.toString();
    int size = marker.getRadius() * 2;
    IconOptions iconOptions = new IconOptions();
    iconOptions.setIconUrl(iconUrl);
    iconOptions.setIconAnchor(new Point(marker.getRadius(), marker.getRadius()));
    iconOptions.setIconSize(new Point(size, size));
    Options markerOptions = new MarkerOptions();
    markerOptions.setProperty("icon", new Icon(iconOptions));
    setModel(markerOptions.getJSObject(), marker);
    return new Marker(toLatLng(marker), markerOptions);
}
Also used : IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions) Options(org.discotools.gwt.leaflet.client.Options) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) SliceValue(org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue) Point(org.discotools.gwt.leaflet.client.types.Point) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker) Point(org.discotools.gwt.leaflet.client.types.Point) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Example 2 with MarkerOptions

use of org.discotools.gwt.leaflet.client.marker.MarkerOptions in project activityinfo by bedatadriven.

the class LeafletMarkerFactory method createIconMapMarker.

/**
 * Creates a Leaflet marker based on an ActivityInfo MapIcon
 */
public static Marker createIconMapMarker(IconMapMarker model) {
    MapIcon iconModel = model.getIcon();
    String iconUrl = "mapicons/" + iconModel.getName() + ".png";
    IconOptions iconOptions = new IconOptions();
    iconOptions.setIconUrl(iconUrl);
    iconOptions.setIconAnchor(new Point(iconModel.getAnchorX(), iconModel.getAnchorY()));
    iconOptions.setIconSize(new Point(iconModel.getWidth(), iconModel.getHeight()));
    Options markerOptions = new MarkerOptions();
    markerOptions.setProperty("icon", new Icon(iconOptions));
    setModel(markerOptions.getJSObject(), model);
    return new Marker(toLatLng(model), markerOptions);
}
Also used : IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions) Options(org.discotools.gwt.leaflet.client.Options) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MarkerOptions(org.discotools.gwt.leaflet.client.marker.MarkerOptions) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) Point(org.discotools.gwt.leaflet.client.types.Point) Icon(org.discotools.gwt.leaflet.client.types.Icon) MapIcon(org.activityinfo.legacy.shared.reports.model.MapIcon) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) CircleMarker(org.discotools.gwt.leaflet.client.marker.CircleMarker) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) MapMarker(org.activityinfo.legacy.shared.reports.content.MapMarker) Marker(org.discotools.gwt.leaflet.client.marker.Marker) IconOptions(org.discotools.gwt.leaflet.client.types.IconOptions)

Aggregations

BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)2 IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)2 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)2 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 MapIcon (org.activityinfo.legacy.shared.reports.model.MapIcon)2 Options (org.discotools.gwt.leaflet.client.Options)2 CircleMarker (org.discotools.gwt.leaflet.client.marker.CircleMarker)2 Marker (org.discotools.gwt.leaflet.client.marker.Marker)2 MarkerOptions (org.discotools.gwt.leaflet.client.marker.MarkerOptions)2 Icon (org.discotools.gwt.leaflet.client.types.Icon)2 IconOptions (org.discotools.gwt.leaflet.client.types.IconOptions)2 Point (org.discotools.gwt.leaflet.client.types.Point)2 SliceValue (org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue)1