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();
}
});
}
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);
}
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();
}
Aggregations