|
From: Christian K. <chr...@go...> - 2011-06-27 07:15:33
|
Hi dudes,
I have a weird problem when I try to add a WMS to my map, which shall be an
overlay. It actually adds the WMS to the OSM map, but only arround the
LatLon(0,0) [which actually is in africa] in two tiles (2 * 256x256 pixel
size) even if it is an world wide map. When I zoom in / out, the overlays
size keep the same (2 * 256x256px).
Additional information:
* Overlay lays correctly on the osm map.
* If WMS is added as a baseLayer, before the osm mapnik was added, the
startview starts at LonLat(0,0) [africa, atlantic]
* In the attachment is an image of the map
I think it has something to do with the startpoint or with the
transformation of the osm general projection"EPSG:900913" to "EPSG:4326"
So please can anyone help me to fix this bug or tell me what I'm doing
wrong?!
It would be very great, thanks for every solution!
Christian Kruse
------------------------
To the code:
* OLmap = new OpenlayersMap("300", "300");*
* OLmap.getMap().addControl(new OverviewMap());*
*
*
* addResizedHandler(new ResizedHandler() {*
* @Override*
* public void onResized(ResizedEvent event) {*
*
*
* try {*
* // listen for window resizing*
* String w = getWidth() - 16 + "";*
* String h = getHeight() - 31 + "";*
* OLmap.getMapWidget().setHeight(h);*
* OLmap.getMapWidget().setWidth(w);*
*
*
* } catch (Exception e) {*
* e.printStackTrace();*
* }*
*
*
* }*
* });*
*
*
* OSMOptions opts = new OSMOptions();*
* opts.getJSObject().setProperty("numZoomLevels", 18);*
* OSM openStreetMap = OSM.Mapnik("OSM Mapnik", opts);*
* openStreetMap.setIsBaseLayer(true);*
*
*
*
*
* WMSParams wmsParams = new WMSParams();*
* wmsParams.setFormat("image/png");*
* wmsParams.setIsTransparent(false);*
* wmsParams.setLayers("basic");*
* wmsParams.setStyles("default");*
* // wmsParams.setMaxExtent(new Bounds(90, 0, 120, 20));*
* wmsParams.setMaxExtent(new Bounds(30, -15, 140, 50));*
*
*
* WMSOptions wmsLayerParams = new WMSOptions();*
* wmsLayerParams.setIsBaseLayer(false);*
* wmsLayerParams.setLayerOpacity(1.0);*
*
*
* WMS wmsLayer = new WMS("basic",
"http://labs.metacarta.com/wms/vmap0",wmsParams,
wmsLayerParams);*
* *
*
*
*
*
* OLmap.getMap().addLayers(new Layer[] { openStreetMap });*
* OLmap.getMap().addLayers(new Layer[] { wmsLayer });*
* OLmap.getMap().addControl(new PanZoomBar());*
* OLmap.getMap().addControl(new NavToolbar());*
* OLmap.getMap().addControl(new MousePosition());*
* OLmap.getMap().addControl(new LayerSwitcher());*
* OLmap.getMap().addControl(new ScaleLine());*
*
*
* double lon = 850000;*
* double lat = 6800000;*
* int zoom = 12;*
* OLmap.getMap().setCenter(new LonLat(lon, lat), zoom);*
*
*
* DockPanel dp = new DockPanel();*
* dp.setHeight("100%");*
* dp.setWidth("100%");*
* dp.add(OLmap.getMapWidget(), DockPanel.CENTER);*
* addItem(dp);*
*}*
*
*
*
*
*
*
*And the OpenLayersMap class:*
*
*
*public class OpenlayersMap extends DockPanel {*
*
*
* private Map map;*
* private MapWidget mapWidget;*
* private String width;*
* private String height;*
*
*
* public OpenlayersMap(String width, String height) {*
* this.width = width;*
* this.height = height;*
*
*
* MapOptions mapOptions = new MapOptions();*
*
*
* mapOptions.setControls(new JObjectArray(new JSObject[] {}));*
* mapOptions.setDisplayProjection(new Projection("EPSG:4326"));*
*
*
* mapWidget = new MapWidget(this.width, this.height, mapOptions);*
* this.map = mapWidget.getMap();*
* }*
*
*
* public String getHeight() {*
* return height;*
* }*
*
*
* public Map getMap() {*
* return map;*
* }*
*
*
* public MapWidget getMapWidget() {*
* return mapWidget;*
* }*
*
*
* public String getWidth() {*
* return width;*
* }*
*
*
* public void setHeight(String height) {*
* this.height = height;*
* }*
*
*
* public void setMap(Map map) {*
* this.map = map;*
* }*
*
*
* public void setMapWidget(MapWidget mapWidget) {*
* this.mapWidget = mapWidget;*
* }*
*
*
* public void setWidth(String width) {*
* this.width = width;*
* }*
*}*
*
*
If you want an image of the result:
http://img825.imageshack.us/img825/9242/wmsbug.png
|