Search in sources :

Example 1 with ScaleLine

use of org.gwtopenmaps.openlayers.client.control.ScaleLine in project kapua by eclipse.

the class DevicesMap method onRender.

protected void onRender(final Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setBorders(false);
    // create some MapOptions
    MapOptions defaultMapOptions = new MapOptions();
    defaultMapOptions.setNumZoomLevels(16);
    defaultMapOptions.removeDefaultControls();
    // Create a MapWidget
    m_mapWidget = new MapWidget("500px", "500px", defaultMapOptions);
    // create the mapquest base layer
    OSMOptions osmOptions = new OSMOptions();
    osmOptions.setAttribution("<p>Tiles Courtesy of <a href=\"http://www.mapquest.com/\" target=\"_blank\">MapQuest</a> <img src=\"http://developer.mapquest.com/content/osm/mq_logo.png\"></p> - &copy; <a href=\"http://www.openstreetmap.org/copyright\" target=\"_blank\">OpenStreetMap</a> contributors");
    OSM mapQuest = new OSM("Map", "http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png", osmOptions);
    mapQuest.setIsBaseLayer(true);
    // Create a marker layer to the current location marker
    m_markerLayer = new Vector(MSGS.devices());
    // add selection
    SelectFeature selectFeature = new SelectFeature(m_markerLayer);
    // And add them to the map
    m_map = m_mapWidget.getMap();
    m_map.addLayer(mapQuest);
    m_map.addLayer(m_markerLayer);
    m_map.addControl(selectFeature);
    // Lets add some default controls to the map
    // Display the scaleline
    m_map.addControl(new Attribution());
    // Display the scaleline
    m_map.addControl(new Navigation());
    // Display the scaleline
    m_map.addControl(new DragPan());
    // Display the scaleline
    m_map.addControl(new PanZoom());
    // Display the scaleline
    m_map.addControl(new ScaleLine());
    // Center and zoom to a location
    // transform lonlat to OSM coordinate system
    // Open a map centered in Amaro, Italy. Required
    LonLat lonLat = new LonLat(13.097, 46.375);
    lonLat.transform(DEFAULT_PROJECTION.getProjectionCode(), m_map.getProjection());
    m_map.setCenter(lonLat, 12);
    add(m_mapWidget);
    // force the map to fall behind popups
    m_mapWidget.getElement().getFirstChildElement().getStyle().setZIndex(0);
}
Also used : PanZoom(org.gwtopenmaps.openlayers.client.control.PanZoom) ScaleLine(org.gwtopenmaps.openlayers.client.control.ScaleLine) Navigation(org.gwtopenmaps.openlayers.client.control.Navigation) MapOptions(org.gwtopenmaps.openlayers.client.MapOptions) OSMOptions(org.gwtopenmaps.openlayers.client.layer.OSMOptions) OSM(org.gwtopenmaps.openlayers.client.layer.OSM) LonLat(org.gwtopenmaps.openlayers.client.LonLat) MapWidget(org.gwtopenmaps.openlayers.client.MapWidget) Attribution(org.gwtopenmaps.openlayers.client.control.Attribution) SelectFeature(org.gwtopenmaps.openlayers.client.control.SelectFeature) Vector(org.gwtopenmaps.openlayers.client.layer.Vector) DragPan(org.gwtopenmaps.openlayers.client.control.DragPan) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Aggregations

FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 LonLat (org.gwtopenmaps.openlayers.client.LonLat)1 MapOptions (org.gwtopenmaps.openlayers.client.MapOptions)1 MapWidget (org.gwtopenmaps.openlayers.client.MapWidget)1 Attribution (org.gwtopenmaps.openlayers.client.control.Attribution)1 DragPan (org.gwtopenmaps.openlayers.client.control.DragPan)1 Navigation (org.gwtopenmaps.openlayers.client.control.Navigation)1 PanZoom (org.gwtopenmaps.openlayers.client.control.PanZoom)1 ScaleLine (org.gwtopenmaps.openlayers.client.control.ScaleLine)1 SelectFeature (org.gwtopenmaps.openlayers.client.control.SelectFeature)1 OSM (org.gwtopenmaps.openlayers.client.layer.OSM)1 OSMOptions (org.gwtopenmaps.openlayers.client.layer.OSMOptions)1 Vector (org.gwtopenmaps.openlayers.client.layer.Vector)1