I'm trying to create a proj4 custom projection for use with my openlayers map. However, when after creating the projection with proj4 I am unable to use it with openlayers projections because ol.proj.get("EPSG:42304") returns a null value.
Here is the relevant code:
proj4.defs("EPSG:42304", "+title=Atlas of Canada, LCC +proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs");
var proj_42304 = ol.proj.get('EPSG:42304');
proj_42304.setExtent("-2687954.60784314","-712631","3560754.60784314","3840000");
The error I am receiving in the console is this:
Uncaught TypeError: Cannot read property 'setExtent' of null
I am using OpenLayers 3.20.1 and Proj4 2.2 for reference. I also have my proj4 script imported after I import the openlayers3 library on my HTML page.
If I change ol.proj.get('EPSG:42304') to ol.proj.get('EPSG:900913') it no longer returns null, which leads me to think it's an error with creating the custom projection.
I am a co-op student and this is my first time working with proj4.
No comments:
Post a Comment