В следующем коде я вызываю сервис геосервера.
Инициализируем карту
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.transform([0,0],'EPSG:4326','EPSG:3857'),
zoom: 2
})
});
Затем я делаю запрос на получение сервиса от геосервера
var sourceVector = new ol.source.Vector({
// The service returns a GML and also allows return 500 polygons
format:new ol.format.GML2({}),
url:'http://localhost:8080/geoserver/siap/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=siap:ppb_curp&maxFeatures=500',
loader: function (extent, resolution, projection) {
//var url = wfsBaseUrl;
$.ajax({
url: 'http://localhost:8080/geoserver/siap/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=siap:ppb_curp&maxFeatures=500',
dataType: "xml",
success: function(response) {
console.log(sourceVector.getProjection());
var gml2format =new ol.format.GML2();
sourceVector.addFeatures(gml2format.readFeatures(response,
{
featureProjection: 'EPSG:4326',
dataProjection: 'EPSG:3857'
}
));
console.log(gml2format.readFeatures(response));
map.getView().fit(sourceVector.getExtent(), map.getSize());
console.log(sourceVector.getExtent());
},
error: function (jqXHR, textStatus, errorThrown) {
alert("The request has failed: " + textStatus);
}
});
}
});
//Vector to add styles to the polygon
var layerVector = new ol.layer.Vector({
name:'test',
source: sourceVector,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 255, 1.0)',
width: 2
})
})
});
map.addLayer(layerVector);
и все хорошо, но полигоны показывают их мне жадным прикрепленным изображением.
Полигоны должны показывать их в районе Мексики, мне нужно преобразование? Любое предложение мне очень поможет ![enter image description here](https://i.stack.imgur.com/Ro5Ff.png)