Search in sources :

Example 1 with LatLngBounds

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;
                    }
                }
            }
        });
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) JSNodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker) NodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMarker) Coordinates(org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates) LatLngBounds(org.discotools.gwt.leaflet.client.types.LatLngBounds) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with LatLngBounds

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);
}
Also used : LatLngBounds(org.discotools.gwt.leaflet.client.types.LatLngBounds) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) LatLng(org.discotools.gwt.leaflet.client.types.LatLng)

Aggregations

LatLngBounds (org.discotools.gwt.leaflet.client.types.LatLngBounds)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)1 LatLng (org.discotools.gwt.leaflet.client.types.LatLng)1 Coordinates (org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates)1 JSNodeMarker (org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker)1 NodeMarker (org.opennms.features.vaadin.nodemaps.internal.gwt.client.NodeMarker)1