0
votes

I'm using this example to import a polygon on an Openlayer map. However I'm having issues with the coordinate formatting. I'm importing the coordinates with a space as the delimiter with a carriage return between lines. I achieve success with a set of example coordinates from the Openlayers example. E.g. -

-5e6 6e6 -5e6 8e6 -3e6 8e6 -3e6 6e6 -5e6 6e6

This format works as it does in the example. However, when I use decimal degree format with the exact code that the examples uses this doesn't work. E.g. -

-83.6743 43.5857 -83.6743 44.0603 -82.4072 44.0603 -82.4072 43.5857 -83.6743 43.5857

Any suggestions would be appreciated.

2

2 Answers

1
votes

Usually you would not want your view in EPSG:4326, so you transform the data from EPSG:4326 projection to display features in the view projection (which is usually EPSG:3857) as in https://openlayers.org/en/latest/examples/wkt.html

1
votes

In the example by OpenLayers the Web Mercator Projection is used. You can see this from the key crs in geojsonObject:

'crs': {
  'type': 'name',
  'properties': {
    'name': 'EPSG:3857',
  },
},

"EPSG:3857" is the code for Web Mercator projection.

However, your coordinates are in the reference system WGS84 (code: "EPSG:4326"). Thus, you need to replace in the example "EPSG:3857" by "EPSG:4326". In addition, you have to adapt center and zoom in new View().