@Override public MapOptions createMapPreviewOption() { MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setNumZoomLevels(18); defaultMapOptions.setProjection("EPSG:900913"); defaultMapOptions.setDisplayProjection(new Projection("EPSG:4326")); defaultMapOptions.setUnits(MapUnits.METERS); defaultMapOptions.setMaxExtent(new Bounds(-20037508, -20037508, 20037508, 20037508.34)); defaultMapOptions.setMaxResolution(new Double(156543.0339).floatValue()); return defaultMapOptions; }
@Override public void buildPanel() { OpenLayers.setProxyHost("olproxy?targetURL="); // create some MapOptions MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setDisplayProjection( new Projection( "EPSG:4326")); // causes the mouse popup to display coordinates in this format defaultMapOptions.setNumZoomLevels(16); // Create a MapWidget MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions); // Create a WMS layer as base layer WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("basic"); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setUntiled(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); String wmsUrl = "http://labs.metacarta.com/wms/vmap0"; WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams); // Add the WMS to the map Map map = mapWidget.getMap(); map.addLayer(wmsLayer); // Adds the graticule control LineSymbolizerOptions lineOptions = new LineSymbolizerOptions(); lineOptions.setStrokeColor("#ccccff"); lineOptions.setStrokeOpacity(0.5); lineOptions.setStrokeWidth(1); LineSymbolizer line = new LineSymbolizer(lineOptions); TextSymbolizerOptions textOptions = new TextSymbolizerOptions(); textOptions.setFontSize("9px"); TextSymbolizer text = new TextSymbolizer(textOptions); final GraticuleOptions grtOptions = new GraticuleOptions(); grtOptions.setTargetSize(200); grtOptions.setLabelled(true); grtOptions.setLineSymbolyzer(line); grtOptions.setLabelSymbolizer(text); Graticule graticule = new Graticule(grtOptions); graticule.setAutoActivate(true); map.addControl(graticule); // Lets add some default controls to the map map.addControl( new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap map.addControl(new ScaleLine()); // Display the scaleline // Center and zoom to a location map.setCenter(new LonLat(146.7, -41.8), 6); contentPanel.add( new HTML("<p>This example shows how to add a custom mouse position to the map..</p>")); contentPanel.add(mapWidget); initWidget(contentPanel); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups }
@Override public void buildPanel() { OpenLayers.setProxyHost("olproxy?targetURL="); // create some MapOptions MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setDisplayProjection( new Projection( "EPSG:4326")); // causes the mouse popup to display coordinates in this format defaultMapOptions.setNumZoomLevels(16); // Create a MapWidget MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions); // Create a WMS layer as base layer WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("basic"); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setUntiled(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); String wmsUrl = "http://labs.metacarta.com/wms/vmap0"; WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams); // Add the WMS to the map Map map = mapWidget.getMap(); map.addLayer(wmsLayer); // Adds the custom mouse position to the map MousePositionOutput mpOut = new MousePositionOutput() { @Override public String format(LonLat lonLat, Map map) { String out = ""; out += "<b>This is the longitude </b> "; out += lonLat.lon(); out += "<b>, and this the latitude</b> "; out += lonLat.lat(); return out; } }; MousePositionOptions mpOptions = new MousePositionOptions(); mpOptions.setFormatOutput(mpOut); // rename to setFormatOutput map.addControl(new MousePosition(mpOptions)); // Lets add some default controls to the map map.addControl( new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap map.addControl(new ScaleLine()); // Display the scaleline // Center and zoom to a location map.setCenter(new LonLat(146.7, -41.8), 6); contentPanel.add( new HTML("<p>This example shows how to add a custom mouse position to the map..</p>")); contentPanel.add(mapWidget); initWidget(contentPanel); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups }
@Override public void buildPanel() { OpenLayers.setProxyHost("olproxy?targetURL="); // create some MapOptions MapOptions defaultMapOptions = new MapOptions(); defaultMapOptions.setDisplayProjection( new Projection( "EPSG:4326")); // causes the mouse popup to display coordinates in this format defaultMapOptions.setNumZoomLevels(16); // Create a MapWidget MapWidget mapWidget = new MapWidget("500px", "500px", defaultMapOptions); // Create a WMS layer as base layer WMSParams wmsParams = new WMSParams(); wmsParams.setFormat("image/png"); wmsParams.setLayers("basic"); wmsParams.setStyles(""); WMSOptions wmsLayerParams = new WMSOptions(); wmsLayerParams.setUntiled(); wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE); String wmsUrl = "http://labs.metacarta.com/wms/vmap0"; WMS wmsLayer = new WMS("Basic WMS", wmsUrl, wmsParams, wmsLayerParams); // Add the WMS to the map Map map = mapWidget.getMap(); map.addLayer(wmsLayer); // Add a measure control to the map MeasureOptions measOpts = new MeasureOptions(); measOpts.setPersist(true); measOpts.setGeodesic(true); // earth is not a cylinder Measure measure = new Measure(new PathHandler(), measOpts); map.addControl(measure); measure.addMeasureListener( new MeasureListener() { public void onMeasure(MeasureEvent eventObject) { Window.alert( "Measured distance is " + eventObject.getMeasure() + " " + eventObject.getUnits()); } }); measure.activate(); // Lets add some default controls to the map map.addControl( new LayerSwitcher()); // + sign in the upperright corner to display the layer switcher map.addControl(new OverviewMap()); // + sign in the lowerright to display the overviewmap map.addControl(new ScaleLine()); // Display the scaleline // Center and zoom to a location map.setCenter(new LonLat(146.7, -41.8), 6); contentPanel.add( new HTML( "<p>This example shows how to add a Measure Control to the map.</p><p>Click on the map to add measure points, end a measurement using double click.</p><p>Note that you could add buttons to enable/disable the measure control on command.</p>")); contentPanel.add(mapWidget); initWidget(contentPanel); mapWidget .getElement() .getFirstChildElement() .getStyle() .setZIndex(0); // force the map to fall behind popups }