Below is a copy of my function, its working without errors. I consloe.log the coords and they are correct, but obviously in 3067 format.

If I remove the code for projection, the 3857 coordinates already saved in database show properly in the polygon, so I am sure that part of the code works. But, I need to project some 3067 coords here also.

I tried a few kinds of projection code from this site but none worked as expected.

I am quite new at mapping code.

  var raster = new TileLayer({
                source: new OSM()

            var coords=this.$store.state.MapsSingle.item.coordinates
            var geojsonObject = {

            'type': 'Feature',
            'geometry': {
            'type': 'Polygon',
            'coordinates': [JSON.parse(coords)]
        var source = new VectorSource({features: (new GeoJSON({
            dataProjection: 'EPSG:3067',
            // featureProjection: 'EPSG:3857'

//I tried these both ways. exchanging the values for dataProjection and featureProjection


      var vector = new VectorLayer({
        source: source,
        style: new Style({
          fill: new Fill({
            color: 'rgba(255, 255, 255, 0.2)'
          stroke: new Stroke({
            color: '#ffcc33',
            width: 2
          image: new CircleStyle({
            radius: 7,
            fill: new Fill({
              color: '#ffcc33'

      var map = new Map({
        layers: [raster, vector],
        target: 'olmap',
        view: new View({
          center: [339042,6673664],
          zoom: 4,
          projection: 'EPSG:3857'
  • if you have set coords=this.$store.state.MapsSingle.item.coordinates are they not already from a json so do you also need JSON.parse ? – Mike Sep 25 '18 at 18:18
  • you would need to define your projection openlayers.org/en/latest/doc/faq.html – JGH Sep 25 '18 at 18:23
  • proj4.default.defs("EPSG:3067", "+proj=utm +zone=35 +ellps=GRS80 +units=m +no_defs"); so the issue was no 'default' before defs. Its still not working, yet, but it exists on the proj4 object. I am checking whats next following your faq – TDawg Sep 25 '18 at 19:12
  • So the remaining error seems to be that I need this: extent = [-3670733.46, 4601971.85, 642319.78, 9362767.00]; ol.proj.get('EPSG:3067').setExtent(extent); But not sure where to put it in the above code – TDawg Sep 25 '18 at 19:16

thank you @JGH you got me going in the right direction. In the end I needed to also add the following. I'll need to test extents a bit more to know if the polygon is drawing.

There is still some strange behavior, but its not related to this question.

proj4.default.defs("EPSG:3067", "+proj=utm +zone=35 +ellps=GRS80 +units=m +no_defs");

var myProjection = new Projection.Projection({
    code: 'EPSG:3067',
    extent: [-3669433.90,1601644.86,348181.26,9364104.12]
  • The strange behaviour I experienced was solved by leaving my map in 3857, and setting dataProjection to 3067 and featureProjection to 3857 and everything works as I planed – TDawg Sep 26 '18 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.