1

I've been trying to do project my map in OpenLayers 4 into Massachusetts Mainland (EPSG:26986). I was following this example: http://openlayers.org/en/latest/examples/scaleline-indiana-east.html but after plugging in the MA Mainland values I just get a blank screen. Here is my code:

<script>
proj4.defs('EPSG=26986', 'PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North_American_Datum_1983",' +
SPHEROID["GRS 1980",6378137,298.257222101]],PRIMEM["Greenwich",0],' +
'UNIT["degree",0.0174532925199433],PROJECTION["Lambert_Conformal_Conic_2SP"],' +
'PARAMETER["false_easting",200000],' +
'PARAMETER["false_northing",750000],' +
'PARAMETER[""central_meridian",-71.5],' +
'PARAMETER["latitude_of_origin",41],' +
'UNIT["metre"]]');

var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
target: 'map',
view: new ol.View({
projection: 'EPSG=26986',
center: ol.proj.fromLonLat([-71, 42], 'EPSG=26986'),
zoom: 7,
extent: ol.proj.transformExtent([-172.54, 23.81, -47.74, 86.46],
'EPSG:4326', 'EPSG=26986'),
minZoom: 6
})
});

map.addControl(new ol.control.ScaleLine({units: 'us'}));
</script>

Does anyone know why this isn't working?

  • You should try changing all 'EPSG=26986' to 'EPSG:26986'. – geraldo Nov 18 '17 at 21:04
1

Your projection declaration is wrong Try this:

proj4.defs("EPSG:26986","+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")

Dont forget to include the pro4js library before declaring your projection definition.

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.