Search in sources :

Example 1 with Bounds

use of org.gwtopenmaps.openlayers.client.Bounds in project opennms by OpenNMS.

the class OpenLayersMapPanel method initializeMap.

/**
     * <p>initializeMap</p>
     */
private void initializeMap() {
    final MapOptions mo = new MapOptions();
    mo.setProjection(PROJECTION_SPHERICAL_MERCATOR.getProjectionCode());
    mo.setDisplayProjection(PROJECTION_LAT_LON);
    mo.setMaxExtent(new Bounds(-180, -90, 180, 90).transform(PROJECTION_LAT_LON, PROJECTION_SPHERICAL_MERCATOR));
    m_mapWidget = new MapWidget("100%", "100%", mo);
    m_mapHolder.add(m_mapWidget);
    m_map = m_mapWidget.getMap();
    m_map.addControl(new PanZoomBar());
    m_map.addControl(new MousePosition());
    m_map.zoomTo(2);
    initializeImageError();
    XYZOptions xyzOptions = new XYZOptions();
    xyzOptions.setSphericalMercator(true);
    xyzOptions.setAttribution(getAttribution());
    XYZ x = new XYZ("OpenStreetMap", getLayerUrl(), xyzOptions);
    x.setIsBaseLayer(true);
    x.setIsVisible(true);
    m_map.addLayer(x);
    m_markersLayer = new Markers("Remote Pollers");
    m_markersLayer.setIsVisible(true);
    m_markersLayer.setIsBaseLayer(false);
    m_map.addLayer(m_markersLayer);
    /*
        final LayerSwitcher switcher = new LayerSwitcher();
        m_map.addControl(switcher);
        */
    m_map.zoomToMaxExtent();
    Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            syncMapSizeWithParent();
        }
    });
}
Also used : MousePosition(org.gwtopenmaps.openlayers.client.control.MousePosition) MapOptions(org.gwtopenmaps.openlayers.client.MapOptions) Bounds(org.gwtopenmaps.openlayers.client.Bounds) XYZOptions(org.gwtopenmaps.openlayers.client.layer.XYZOptions) Markers(org.gwtopenmaps.openlayers.client.layer.Markers) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) XYZ(org.gwtopenmaps.openlayers.client.layer.XYZ) MapWidget(org.gwtopenmaps.openlayers.client.MapWidget) PanZoomBar(org.gwtopenmaps.openlayers.client.control.PanZoomBar) ResizeEvent(com.google.gwt.event.logical.shared.ResizeEvent)

Example 2 with Bounds

use of org.gwtopenmaps.openlayers.client.Bounds in project opennms by OpenNMS.

the class OpenLayersMapPanel method toBounds.

private static Bounds toBounds(final GWTBounds bounds) {
    Bounds b = null;
    if (bounds == null) {
        b = new Bounds(-180, -90, 180, 90);
    } else {
        final GWTLatLng nec = bounds.getNorthEastCorner();
        final GWTLatLng swc = bounds.getSouthWestCorner();
        b = new Bounds(swc.getLongitude(), swc.getLatitude(), nec.getLongitude(), nec.getLatitude());
    }
    return b.transform(PROJECTION_LAT_LON, PROJECTION_SPHERICAL_MERCATOR);
}
Also used : Bounds(org.gwtopenmaps.openlayers.client.Bounds)

Example 3 with Bounds

use of org.gwtopenmaps.openlayers.client.Bounds in project opennms by OpenNMS.

the class OpenLayersMapPanel method toGWTBounds.

private static GWTBounds toGWTBounds(final Bounds fromBounds) {
    if (fromBounds == null) {
        return new GWTBounds(-180, -90, 180, 90);
    }
    final Bounds bounds = fromBounds.transform(PROJECTION_SPHERICAL_MERCATOR, PROJECTION_LAT_LON);
    BoundsBuilder bldr = new BoundsBuilder();
    bldr.extend(Math.max(-90, bounds.getLowerLeftY()), Math.max(-180, bounds.getLowerLeftX()));
    bldr.extend(Math.min(90, bounds.getUpperRightY()), Math.min(180, bounds.getUpperRightX()));
    return bldr.getBounds();
}
Also used : Bounds(org.gwtopenmaps.openlayers.client.Bounds) BoundsBuilder(org.opennms.features.poller.remote.gwt.client.utils.BoundsBuilder)

Aggregations

Bounds (org.gwtopenmaps.openlayers.client.Bounds)3 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 MapOptions (org.gwtopenmaps.openlayers.client.MapOptions)1 MapWidget (org.gwtopenmaps.openlayers.client.MapWidget)1 MousePosition (org.gwtopenmaps.openlayers.client.control.MousePosition)1 PanZoomBar (org.gwtopenmaps.openlayers.client.control.PanZoomBar)1 Markers (org.gwtopenmaps.openlayers.client.layer.Markers)1 XYZ (org.gwtopenmaps.openlayers.client.layer.XYZ)1 XYZOptions (org.gwtopenmaps.openlayers.client.layer.XYZOptions)1 BoundsBuilder (org.opennms.features.poller.remote.gwt.client.utils.BoundsBuilder)1