Search in sources :

Example 1 with PanZoomBar

use of org.gwtopenmaps.openlayers.client.control.PanZoomBar 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)

Aggregations

ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 Bounds (org.gwtopenmaps.openlayers.client.Bounds)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