use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates in project opennms by OpenNMS.
the class NodeMapWidget method removeDisabledMarkers.
private void removeDisabledMarkers() {
// remove disabled markers
final List<JSNodeMarker> disabledMarkers = m_markerContainer.getDisabledMarkers();
LOG.info("NodeMapWidget.removeDisabledMarkers(): removing " + disabledMarkers.size() + " disabled markers from the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = disabledMarkers.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
marker.closePopup();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.removeDisabledMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
m_stateClusterGroups[stateId].removeLayer(marker);
} else {
m_markerClusterGroup.removeLayer(marker);
}
return true;
}
LOG.info("NodeMapWidget.removeDisabledMarkers(): finished removing filtered markers (" + disabledMarkers.size() + " entries)");
return false;
}
});
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates in project opennms by OpenNMS.
the class NodeMapWidget method addNewMarkers.
private void addNewMarkers() {
// add new markers
LOG.info("NodeMapWidget.addNewMarkers(): adding " + m_markerContainer.size() + " markers to the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = m_markerContainer.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.addNewMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(coordinates.latitude, coordinates.longitude, StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
if (!m_stateClusterGroups[stateId].hasLayer(marker)) {
m_stateClusterGroups[stateId].addLayer(marker);
}
} else {
if (!m_markerClusterGroup.hasLayer(marker)) {
m_markerClusterGroup.addLayer(marker);
}
}
return true;
}
LOG.info("NodeMapWidget.addNewMarkers(): finished adding visible markers (" + m_markerContainer.size() + " entries)");
return false;
}
});
}
use of org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates in project opennms by OpenNMS.
the class NodeMapWidget method zoomToFit.
private void zoomToFit() {
// zoom on first run
if (m_firstUpdate) {
LOG.info("NodeMapWidget.zoomToFit(): first update, zooming to bounds.");
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if (m_firstUpdate) {
final List<JSNodeMarker> allMarkers = m_markerContainer.getAllMarkers();
if (allMarkers.size() == 0) {
LOG.info("NodeMapWidget.zoomToFit(): no bounds yet, skipping.");
} else {
final LatLngBounds bounds = new LatLngBounds();
for (final NodeMarker marker : allMarkers) {
LOG.info("NodeMapWidget.zoomToFit(): processing marker: " + marker);
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.zoomToFit(): no coordinates found for marker! " + marker);
} else {
bounds.extend(JSNodeMarker.coordinatesToLatLng(coordinates));
}
}
LOG.info("NodeMapWidget.zoomToFit(): setting boundary to " + bounds.toBBoxString() + ".");
m_map.fitBounds(bounds);
m_firstUpdate = false;
}
}
}
});
}
}
Aggregations