我想在我的apache wicket應用程序中包含一個開放式街道地圖小部件。使用來自wicket-stuff所述wicket-contrib-openlayers分量Im與以下代碼:Wicket:Openlayers Integration&Open Streetmaps Layer
List<Layer> layers = new ArrayList<Layer>();
Layer layerOSMTilesAtHome = new OSM("Osmarender", OSMLayer.TilesAtHome);
Layer layerOSMMapnik = new OSM("Mapnik", OSMLayer.Mapnik);
Layer layerOSMCycleMap = new OSM("CycleMap", OSMLayer.CycleMap);
layers.add(layerOSMMapnik);
layers.add(layerOSMTilesAtHome);
layers.add(layerOSMCycleMap);
HashMap<String, String> mapOptions = new HashMap<String, String>();
Bounds boundsExtend = new Bounds(new LonLat(-20037508.34, -20037508.34), new LonLat(20037508.34, 20037508.34));
mapOptions.put("maxExtent", boundsExtend.getJSconstructor());
mapOptions.put("projection", "new OpenLayers.Projection('EPSG:900913')");
mapOptions.put("displayProjection", "new OpenLayers.Projection('EPSG:4326')");
mapOptions.put("units", "'meters'");
mapOptions.put("maxResolution", "156543");
mapOptions.put("numZoomLevels", "18");
OpenLayersMap map = new OpenLayersMap("map", layers, mapOptions);
map.addControl(Control.LayerSwitcher);
map.addControl(Control.MousePosition);
map.addControl(Control.KeyboardDefaults);
add(map);
這是一個1:從部件的SimpleOpenStreetMapExample的1個拷貝。現在的問題是:如何設置地圖的中心。我試了
map.setCenter(new LonLat(5, 50), 13);
之後的「添加(map);」從上面的代碼。這不起作用,地圖不會改變。林不知道單位經度和緯度都在,我也試圖將它們轉換使用此方法墨卡託-系統:
private static double lon2Merc(double lon) {
return 20037508.34*lon/180.0;
}
private static double lat2Merc(double lat) {
lat = Math.log(Math.tan((90.0 + lat)*Math.PI/360.0))/(Math.PI/180.0);
return 20037508.34*lat/180.0;
}
但這並不幫助,沒有什麼變化。
因此:任何人都可以發表一個簡短的例子,如何將OSM-Map嵌入Wicket以及如何設置中心和縮放級別?
謝謝!