Search in sources :

Example 6 with Options

use of org.discotools.gwt.leaflet.client.Options in project opennms by OpenNMS.

the class NodeMapWidget method addMarkerLayer.

private void addMarkerLayer() {
    LOG.info("NodeMapWidget.addMarkerLayer()");
    if (m_markerClusterGroup != null) {
        m_map.removeLayer(m_markerClusterGroup);
    }
    final Options markerClusterOptions = new Options();
    markerClusterOptions.setProperty("zoomToBoundsOnClick", false);
    markerClusterOptions.setProperty("iconCreateFunction", new IconCreateCallback());
    // markerClusterOptions.setProperty("disableClusteringAtZoom", 13);
    m_markerClusterGroup = new MarkerClusterGroup(markerClusterOptions);
    final NodeMarkerClusterCallback callback = new NodeMarkerClusterCallback();
    m_markerClusterGroup.on("clusterclick", callback);
    m_markerClusterGroup.on("clustertouchend", callback);
    m_map.addLayer(m_markerClusterGroup);
    m_stateClusterGroups = new MarkerClusterGroup[52];
    LOG.info("Creating marker cluster with maximum cluster radius " + m_maxClusterRadius);
    final Options[] stateClusterOptions = new Options[m_stateClusterGroups.length];
    for (int i = 0; i < m_stateClusterGroups.length; i++) {
        // stateClusterOptions[i] = new Options();
        stateClusterOptions[i] = markerClusterOptions;
        stateClusterOptions[i].setProperty("maxClusterRadius", m_maxClusterRadius > 0 ? m_maxClusterRadius : 350);
        stateClusterOptions[i].setProperty("inUs", true);
        stateClusterOptions[i].setProperty("stateID", i);
        stateClusterOptions[i].setProperty("stateData", StatesData.getPolygonInfo(i, StatesData.getInstance()));
        // stateClusterOptions[i].setProperty("zoomToBoundsOnClick", false);
        // stateClusterOptions[i].setProperty("iconCreateFunction", new IconCreateCallback());
        m_stateClusterGroups[i] = new MarkerClusterGroup(stateClusterOptions[i]);
        m_stateClusterGroups[i].on("clusterclick", callback);
        m_stateClusterGroups[i].on("clustertouchend", callback);
        m_map.addLayer(m_stateClusterGroups[i]);
    }
}
Also used : MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) Options(org.discotools.gwt.leaflet.client.Options) ZoomOptions(org.discotools.gwt.leaflet.client.controls.zoom.ZoomOptions) NodeMarkerClusterCallback(org.opennms.features.vaadin.nodemaps.internal.gwt.client.event.NodeMarkerClusterCallback) IconCreateCallback(org.opennms.features.vaadin.nodemaps.internal.gwt.client.event.IconCreateCallback)

Example 7 with Options

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

the class LocationMap method afterRender.

@Override
protected void afterRender() {
    super.afterRender();
    Extents countryBounds = searchPresenter.getCountryBounds();
    MapOptions mapOptions = new MapOptions();
    mapOptions.setCenter(new LatLng(countryBounds.getCenterY(), countryBounds.getCenterX()));
    mapOptions.setZoom(6);
    mapOptions.setProperty("crs", new EPSG3857());
    TileLayer baseLayer = new TileLayer(MapboxLayers.MAPBOX_STREETS, new Options());
    markerLayer = new LayerGroup(new ILayer[0]);
    map = new Map(getElement().getElementsByTagName("div").getItem(0), mapOptions);
    map.addLayer(baseLayer);
    map.addLayer(markerLayer);
    bindEvents();
}
Also used : EPSG3857(org.discotools.gwt.leaflet.client.crs.epsg.EPSG3857) MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) Options(org.discotools.gwt.leaflet.client.Options) TileLayer(org.discotools.gwt.leaflet.client.layers.raster.TileLayer) MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) ILayer(org.discotools.gwt.leaflet.client.layers.ILayer) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) LayerGroup(org.discotools.gwt.leaflet.client.layers.others.LayerGroup) Extents(org.activityinfo.model.type.geo.Extents) Map(org.discotools.gwt.leaflet.client.map.Map)

Example 8 with Options

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

the class LeafletMarkerFactory method create.

public static Marker create(MapMarker mapMarker, final EventHandler... markerEventHandlers) {
    final Marker marker;
    if (mapMarker instanceof IconMapMarker) {
        marker = createIconMapMarker((IconMapMarker) mapMarker);
    } else if (mapMarker instanceof PieMapMarker) {
        marker = createPieMapMarker((PieMapMarker) mapMarker);
    } else if (mapMarker instanceof BubbleMapMarker) {
        marker = createBubbleMapMarker((BubbleMapMarker) mapMarker);
    } else {
        final Options options = new Options();
        setModel(options.getJSObject(), mapMarker);
        marker = new Marker(toLatLng(mapMarker), options);
    }
    if (markerEventHandlers != null) {
        for (EventHandler handler : markerEventHandlers) {
            EventHandlerManager.addEventHandler(marker, EventHandler.Events.click, handler);
        }
    }
    return marker;
}
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) IconMapMarker(org.activityinfo.legacy.shared.reports.content.IconMapMarker) PieMapMarker(org.activityinfo.legacy.shared.reports.content.PieMapMarker) EventHandler(org.discotools.gwt.leaflet.client.events.handler.EventHandler) BubbleMapMarker(org.activityinfo.legacy.shared.reports.content.BubbleMapMarker) 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)

Example 9 with Options

use of org.discotools.gwt.leaflet.client.Options 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)

Example 10 with Options

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

the class LeafletReportOverlays method setBaseMap.

public void setBaseMap(BaseMap baseMap) {
    TileBaseMap tileBaseMap = MapboxLayers.toTileBaseMap(baseMap);
    if (!Objects.equal(currentBaseMap, tileBaseMap)) {
        if (baseLayer != null) {
            mapWidget.removeLayer(baseLayer);
        }
        Options options = new Options();
        options.setProperty("minZoom", tileBaseMap.getMinZoom());
        options.setProperty("maxZoom", tileBaseMap.getMaxZoom());
        baseLayer = new TileLayer(tileBaseMap.getTileUrlPattern(), options);
        mapWidget.addLayer(baseLayer, true);
        if (mapWidget.getZoom() > tileBaseMap.getMaxZoom()) {
            mapWidget.setZoom(tileBaseMap.getMaxZoom());
        }
        if (mapWidget.getZoom() < tileBaseMap.getMinZoom()) {
            mapWidget.setZoom(tileBaseMap.getMinZoom());
        }
    }
}
Also used : Options(org.discotools.gwt.leaflet.client.Options) GeoJSONOptions(org.discotools.gwt.leaflet.client.layers.others.GeoJSONOptions) TileLayer(org.discotools.gwt.leaflet.client.layers.raster.TileLayer) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap)

Aggregations

Options (org.discotools.gwt.leaflet.client.Options)10 MapOptions (org.discotools.gwt.leaflet.client.map.MapOptions)5 Marker (org.discotools.gwt.leaflet.client.marker.Marker)5 CircleMarker (org.discotools.gwt.leaflet.client.marker.CircleMarker)4 MarkerOptions (org.discotools.gwt.leaflet.client.marker.MarkerOptions)4 IconOptions (org.discotools.gwt.leaflet.client.types.IconOptions)4 BubbleMapMarker (org.activityinfo.legacy.shared.reports.content.BubbleMapMarker)3 IconMapMarker (org.activityinfo.legacy.shared.reports.content.IconMapMarker)3 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)3 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)3 TileLayer (org.discotools.gwt.leaflet.client.layers.raster.TileLayer)3 MapIcon (org.activityinfo.legacy.shared.reports.model.MapIcon)2 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)2 ZoomOptions (org.discotools.gwt.leaflet.client.controls.zoom.ZoomOptions)2 Icon (org.discotools.gwt.leaflet.client.types.Icon)2 Point (org.discotools.gwt.leaflet.client.types.Point)2 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 StoreEvent (com.extjs.gxt.ui.client.store.StoreEvent)1 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)1 SliceValue (org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue)1