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]);
}
}
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();
}
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;
}
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);
}
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());
}
}
}
Aggregations