我在一個家庭項目中使用Leafletjs(這是它看起來,現在。 但我找不到必須設置投影,我發現它爲OpenLayers,看起來像這樣:Leafletjs上的設置投影
// Openlayers settings
//var defaultMaxExtent = new OpenLayers.Bounds(427304, 6032920, 927142, 6485144);
var defaultMaxExtent = new OpenLayers.Bounds(427304, 6032920, 927142, 6485144);
var defaultProjection = "EPSG:25832";
var defaultUnits = "Meters";
var defaultResolutions = new Array(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024);
var defaultExtent = new OpenLayers.Bounds(215446, 2103547, 706886, 6203897); //this extent is used when the page is loaded.
//var defaultExtent = new OpenLayers.Bounds(705446, 6203547, 706886, 6203897); //this extent is used when the page is loaded.
map = new OpenLayers.Map('map', { projection: defaultProjection, units: defaultUnits, maxExtent: defaultMaxExtent, resolutions: defaultResolutions, controls: [
// Hide controls by default
new OpenLayers.Control.Navigation({ wheelChange: HideInfoBox() }),
new OpenLayers.Control.ArgParser(),
new OpenLayers.Control.Attribution()]
});
layer = new OpenLayers.Layer.WMS("kort", "http://serverAddress?", { nbr: '', username: 'admin', password: 'adminadmin', layers: 'Overlayer', format: 'image/png' });
任何人都可以幫助我
更新: 我試圖從單張採取標準投影和定製它,像這樣
L.CRS.EPSG25832 = L.extend({}, L.CRS, {
code: 'EPSG:25832',
projection: L.Projection.SphericalMercator,
transformation: new L.Transformation(0.5/Math.PI, 0.5, -0.5/Math.PI, 0.5),
project: function (latlng) { // (LatLng) -> Point
var projectedPoint = this.projection.project(latlng),
earthRadius = 6378137;
return projectedPoint.multiplyBy(earthRadius);
}
});
現在投影是正確的。但現在的問題是座標是錯誤的,所以例如,如果我從Leaflet獲得座標,Kolding現在在法國中部而不是在丹麥。
也許源的幫助:https://github.com/Leaflet/Leaflet/blob/master/src/map/Map.js#L10和https://github.com/單張/單張/樹/主/ src目錄/地理/ CRS。 – tbicr 2013-03-05 14:12:12
怎麼回事? – flup 2013-03-05 17:26:41
@flup應該更像這張圖片從源https://dl.dropbox.com/u/2230967/DKv2.PNG – mortenstarck 2013-03-06 06:32:24