我在2天前问了同样的问题,但我仍然在努力解决这个问题。 我在RT90中有一个shapefile。 2.我在ArcMap中将它重新投影到WGS_1984_Web_Mercator_Auxiliary_Sphere(epsg3857) 3.在GeoServer中,Native SRS为空白(甚至未显示为Unknown),并且Declared SRS设置为3857,因为4326由于某种原因(在图层预览中没有图像)不起作用。 GeoSever中的WMS层是这样的:
它在浏览器中被扭曲:
这是我的代码:
<script src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.js"></script>
<script defer="defer" type="text/javascript">
var lon = 13.2;
var lat = 55.7;
var zoom = 10;
var bounds = new OpenLayers.Bounds(
1460205.410400961, 7494354.925820643,
1476383.1814075545, 7510328.218502053
);
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 63.194417994505784,
projection: "EPSG:3857",
units: 'm'
};
var map, vectors, controls;
function init(){
var map = new OpenLayers.Map({
div: "map",
allOverlays: true
});
var build1_wms = new OpenLayers.Layer.WMS( "Building",
"http://localhost:8090/geoserver/wms/wsNYCRoad", {
layers: 'bygg_lant_p',
styles: '',
transparent:true,
tiled: 'ture',
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
},
{
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true,
yx : {'EPSG:3857' : false}
});
map.addLayers([build1_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
我也试图添加它,但它没有帮助:
var EPSG4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG3857 = new OpenLayers.Projection("EPSG:3857 ");
请帮我弄清楚如何解决问题!
答案 0 :(得分:0)
我解决了问题:
var map = new OpenLayers.Map({
maxScale: 1/5000,
minScale: 1/500000,
projection: new OpenLayers.Projection("EPSG:3857"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
div: "map",
allOverlays: true
});
.
.
.
var proj = new OpenLayers.Projection("EPSG:4326");
var lonlat = new OpenLayers.LonLat(1468582.90048, 7501836.76895);
lonlat.transform(proj, map.getProjectionObject());
map.setCenter(lonlat, 5);