Estoy tratando de mostrar un polígono sobre una ciudad usando GeoJSON, he validado el archivo usando http://www.mapshaper.org/ y el polígono se muestra bien, pero cuando intento mostrar esta capa sobre una capa de OpenStreetMap (OSM) no veo nada.
Este es mi código:
var data = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2039" } }, "features": [ { "type": "Feature", "properties": { "id": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 179029.98345868432, 667951.77896603046 ], [ 179242.5448687863, 667376.61279751919 ], [ 179417.59544181143, 667201.56222449406 ], [ 181343.15174508799, 667551.66337054444 ], [ 181718.26011585613, 667714.21033121063 ], [ 181418.17341924162, 666526.36715711141 ], [ 181243.12284621646, 665576.09261783212 ], [ 181155.59755970389, 665288.50953357643 ], [ 181443.18064395949, 665025.93367403874 ], [ 181280.63368329327, 664375.74583137396 ], [ 181118.08672262708, 663713.05437635025 ], [ 181193.10839678071, 663400.4640673768 ], [ 181405.66980688268, 663450.47851681255 ], [ 181555.71315518994, 663412.96767973574 ], [ 181768.27456529188, 663200.40626963368 ], [ 182043.35403718855, 662962.83763481386 ], [ 181893.31068888129, 662662.75093819934 ], [ 182468.47685739247, 662212.62089327758 ], [ 182518.49130682822, 661349.87164051086 ], [ 182455.97324503353, 660874.7343708711 ], [ 181843.29623944554, 659786.92009564349 ], [ 180242.83385750139, 660949.75604502473 ], [ 179830.21464965641, 661387.38247758767 ], [ 179205.03403170948, 660537.13683717977 ], [ 178042.19808232816, 660424.60432594933 ], [ 177767.11861043153, 660599.65489897446 ], [ 177166.94521720248, 660537.13683717977 ], [ 176604.28266105024, 660524.63322482083 ], [ 176144.77490685924, 660612.15851133352 ], [ 176032.2423956288, 660887.23798323015 ], [ 176107.26406978242, 661549.92943825398 ], [ 176344.83270460228, 662362.66424158495 ], [ 176894.99164839557, 662725.26899999415 ], [ 177170.07112029221, 662837.80151122459 ], [ 177482.66142926569, 663162.89543255698 ], [ 177545.17949106038, 663738.06160106824 ], [ 177557.68310341932, 664000.63746060594 ], [ 177732.73367644445, 664113.16997183638 ], [ 178207.87094608412, 665701.12874142162 ], [ 178020.31676070005, 665876.17931444675 ], [ 177982.80592362324, 666151.25878634339 ], [ 178370.41790675034, 666126.25156162551 ], [ 178570.47570449335, 667101.53332562267 ], [ 178958.08768762046, 667826.74284244119 ], [ 179029.98345868432, 667951.77896603046 ] ] ] } } ] }';
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Vector({
source: new ol.source.Vector({
object: data,
format: new ol.format.GeoJSON()
})
})
]
});
var telAviv = ol.proj.transform([34.81185, 32.04314], 'EPSG:4326', 'EPSG:3857');
map.setView(
new ol.View({
center: telAviv,
zoom: 10
})
);
Fíjate en las coordenadas que me ha proporcionado el cliente, no sé cómo proyectarlas en el mapa sobre la ciudad de Tel Aviv.
Estoy usando la versión 3.16.0 de OpenLayers.
Enlace a JSFiddle .