use of org.discotools.gwt.leaflet.client.types.LatLngBounds 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;
}
}
}
});
}
}
use of org.discotools.gwt.leaflet.client.types.LatLngBounds in project activityinfo by bedatadriven.
the class LeafletUtil method newLatLngBounds.
public static LatLngBounds newLatLngBounds(Extents bounds) {
LatLng southWest = new LatLng(bounds.getMinLat(), bounds.getMinLon());
LatLng northEast = new LatLng(bounds.getMaxLat(), bounds.getMaxLon());
return new LatLngBounds(southWest, northEast);
}
Aggregations