Using Proj4js with OpenLayers to transform lat lng from 4326 to 27700 but coming out unchangedUsing Proj4js in Openlayers - Proj4js is not definedOpenLayers/proj4js and the EPSG:27700 (UK) ProjectionOpenLayers transform EPSG 27700 coordinate to Google 900913Problems with features, popups and strategy with OpenLayersOpenLayers.Bounds transform not working as expectedGet Lat & Lng from GeoDjango OSMGeoAdminOpenlayers Transform not transforming a point from EPSG 27700 to EPSG 4326Using Proj4js in Openlayers - Proj4js is not definedUsing OSGB (ESPG: 27700) projection in Openlayers with MousePositionOpenLayers and proj4js.defs() - why does one custom projection work and not the other?Problem on changing the EPSG:3376 to EPSG:4326 using Proj4js
What is the maximum number of net attacks that one can make in a round?
How does an ordinary object become radioactive?
How come the nude protesters were not arrested?
Meaning of 'lose their grip on the groins of their followers'
How can this tool find out registered domains from an IP?
Wooden cooking layout
Cascading Switches. Will it affect performance?
How do I prevent employees from either switching to competitors or opening their own business?
SQL counting distinct over partition
How did old MS-DOS games utilize various graphic cards?
How to handle self harm scars on the arm in work environment?
Are there any important biographies of nobodies?
How can I end combat quickly when the outcome is inevitable?
Soft question: Examples where lack of mathematical rigour cause security breaches?
Check if three arrays contains the same element
When would it be advantageous not apply Training Ground's cost reduction?
How to hide an urban landmark?
Is White controlling this game?
What speaks against investing in precious metals?
Does the Long March-11 increase its thrust after clearing the launch tower?
Playing a Character as Unobtrusive and Subservient, Yet Not Passive
Why didn't Voldemort recognize that Dumbledore was affected by his curse?
Should I give professor gift at the beginning of my PhD?
How do governments keep track of their issued currency?
Using Proj4js with OpenLayers to transform lat lng from 4326 to 27700 but coming out unchanged
Using Proj4js in Openlayers - Proj4js is not definedOpenLayers/proj4js and the EPSG:27700 (UK) ProjectionOpenLayers transform EPSG 27700 coordinate to Google 900913Problems with features, popups and strategy with OpenLayersOpenLayers.Bounds transform not working as expectedGet Lat & Lng from GeoDjango OSMGeoAdminOpenlayers Transform not transforming a point from EPSG 27700 to EPSG 4326Using Proj4js in Openlayers - Proj4js is not definedUsing OSGB (ESPG: 27700) projection in Openlayers with MousePositionOpenLayers and proj4js.defs() - why does one custom projection work and not the other?Problem on changing the EPSG:3376 to EPSG:4326 using Proj4js
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Using Proj4js to transform lat lng from 4326 to 27700 but coming out unchanged. I am using OpenLayers 2.12 (OS API Leisure map) EPSG 27700, Proj4js (CDN)
I have added the definition to proj4
epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
// To
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
console.log(lonLat);
lonLat is coming out as lon: -0.1279688, lat: 51.5077286 so unchanged.
I think I'm missing a trick.
openlayers-2 proj4js
add a comment |
Using Proj4js to transform lat lng from 4326 to 27700 but coming out unchanged. I am using OpenLayers 2.12 (OS API Leisure map) EPSG 27700, Proj4js (CDN)
I have added the definition to proj4
epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
// To
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
console.log(lonLat);
lonLat is coming out as lon: -0.1279688, lat: 51.5077286 so unchanged.
I think I'm missing a trick.
openlayers-2 proj4js
add a comment |
Using Proj4js to transform lat lng from 4326 to 27700 but coming out unchanged. I am using OpenLayers 2.12 (OS API Leisure map) EPSG 27700, Proj4js (CDN)
I have added the definition to proj4
epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
// To
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
console.log(lonLat);
lonLat is coming out as lon: -0.1279688, lat: 51.5077286 so unchanged.
I think I'm missing a trick.
openlayers-2 proj4js
Using Proj4js to transform lat lng from 4326 to 27700 but coming out unchanged. I am using OpenLayers 2.12 (OS API Leisure map) EPSG 27700, Proj4js (CDN)
I have added the definition to proj4
epsg4326 = new OpenLayers.Projection("EPSG:4326"); //WGS 1984 projection
// To
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
console.log(lonLat);
lonLat is coming out as lon: -0.1279688, lat: 51.5077286 so unchanged.
I think I'm missing a trick.
openlayers-2 proj4js
openlayers-2 proj4js
edited May 22 at 12:37
Ian Turton♦
51.3k548121
51.3k548121
asked May 22 at 12:24
Simon JeffsSimon Jeffs
111
111
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
transform
converts the point in place so no new point is returned. See the documentation:
Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first.
So you want something like:
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286);
lonLat.transform(epsg4326, EPSG27700);
console.log(lonLat);
The transformation is in place, but it still returns the result, for example inmap.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
add a comment |
OpenLayers 2 uses an earlier proj4 (version 1.1.0) syntax:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs ";
or with proj4 version 2:
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.Proj4js =
Proj: function(code)
return proj4(Proj4js.defs[code]);
,
defs: proj4.defs,
transform: proj4
;
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
alert(lonLat.lon + ' ' + lonLat.lat);
</script>
</body>
</html>
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
add a comment |
Ok, I figured out my issue. I looked at the post Mike shared Using Proj4js in Openlayers - Proj4js is not defined and tried the example code in my project which still failed. That narrowed it down to the js references. So I copied the references and et voila; success!
My references:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4-src.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js
Changed to:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js
Note that it worked with both versions of OpenLayers js file but not when using 2.5.0.
Thanks to Ian and Mike for helping!
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f323552%2fusing-proj4js-with-openlayers-to-transform-lat-lng-from-4326-to-27700-but-coming%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
transform
converts the point in place so no new point is returned. See the documentation:
Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first.
So you want something like:
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286);
lonLat.transform(epsg4326, EPSG27700);
console.log(lonLat);
The transformation is in place, but it still returns the result, for example inmap.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
add a comment |
transform
converts the point in place so no new point is returned. See the documentation:
Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first.
So you want something like:
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286);
lonLat.transform(epsg4326, EPSG27700);
console.log(lonLat);
The transformation is in place, but it still returns the result, for example inmap.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
add a comment |
transform
converts the point in place so no new point is returned. See the documentation:
Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first.
So you want something like:
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286);
lonLat.transform(epsg4326, EPSG27700);
console.log(lonLat);
transform
converts the point in place so no new point is returned. See the documentation:
Transform the LonLat object from source to dest. This transformation is in place: if you want a new lonlat, use .clone() first.
So you want something like:
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286);
lonLat.transform(epsg4326, EPSG27700);
console.log(lonLat);
answered May 22 at 12:36
Ian Turton♦Ian Turton
51.3k548121
51.3k548121
The transformation is in place, but it still returns the result, for example inmap.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
add a comment |
The transformation is in place, but it still returns the result, for example inmap.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
The transformation is in place, but it still returns the result, for example in
map.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
The transformation is in place, but it still returns the result, for example in
map.setCenter(new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()));
– Mike
May 22 at 13:06
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
Thanks for the tip, however both still output the original lat/lng
– Simon Jeffs
May 22 at 13:28
add a comment |
OpenLayers 2 uses an earlier proj4 (version 1.1.0) syntax:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs ";
or with proj4 version 2:
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.Proj4js =
Proj: function(code)
return proj4(Proj4js.defs[code]);
,
defs: proj4.defs,
transform: proj4
;
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
alert(lonLat.lon + ' ' + lonLat.lat);
</script>
</body>
</html>
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
add a comment |
OpenLayers 2 uses an earlier proj4 (version 1.1.0) syntax:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs ";
or with proj4 version 2:
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.Proj4js =
Proj: function(code)
return proj4(Proj4js.defs[code]);
,
defs: proj4.defs,
transform: proj4
;
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
alert(lonLat.lon + ' ' + lonLat.lat);
</script>
</body>
</html>
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
add a comment |
OpenLayers 2 uses an earlier proj4 (version 1.1.0) syntax:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs ";
or with proj4 version 2:
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.Proj4js =
Proj: function(code)
return proj4(Proj4js.defs[code]);
,
defs: proj4.defs,
transform: proj4
;
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
alert(lonLat.lon + ' ' + lonLat.lat);
</script>
</body>
</html>
OpenLayers 2 uses an earlier proj4 (version 1.1.0) syntax:
Proj4js.defs["EPSG:27700"] = "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs ";
or with proj4 version 2:
<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.Proj4js =
Proj: function(code)
return proj4(Proj4js.defs[code]);
,
defs: proj4.defs,
transform: proj4
;
proj4.defs("EPSG:27700","+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs");
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG27700 = new OpenLayers.Projection("EPSG:27700");
var lonLat = new OpenLayers.LonLat(-0.1279688, 51.5077286).transform(epsg4326, EPSG27700);
alert(lonLat.lon + ' ' + lonLat.lat);
</script>
</body>
</html>
edited May 22 at 16:21
answered May 22 at 12:54
MikeMike
3,025139
3,025139
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
add a comment |
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
If you are using the OS API some transforms are built in openspace.ordnancesurvey.co.uk/docs/4.0.0/files/OpenSpace/…
– Mike
May 22 at 12:58
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
We were using the openspace api but are migrating to the OS API apidocs.os.uk/docs/os-maps-overview so have to remove the OpenSpace reference
– Simon Jeffs
May 22 at 13:06
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
see also gis.stackexchange.com/questions/120021/…
– Mike
May 22 at 13:32
add a comment |
Ok, I figured out my issue. I looked at the post Mike shared Using Proj4js in Openlayers - Proj4js is not defined and tried the example code in my project which still failed. That narrowed it down to the js references. So I copied the references and et voila; success!
My references:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4-src.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js
Changed to:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js
Note that it worked with both versions of OpenLayers js file but not when using 2.5.0.
Thanks to Ian and Mike for helping!
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
add a comment |
Ok, I figured out my issue. I looked at the post Mike shared Using Proj4js in Openlayers - Proj4js is not defined and tried the example code in my project which still failed. That narrowed it down to the js references. So I copied the references and et voila; success!
My references:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4-src.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js
Changed to:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js
Note that it worked with both versions of OpenLayers js file but not when using 2.5.0.
Thanks to Ian and Mike for helping!
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
add a comment |
Ok, I figured out my issue. I looked at the post Mike shared Using Proj4js in Openlayers - Proj4js is not defined and tried the example code in my project which still failed. That narrowed it down to the js references. So I copied the references and et voila; success!
My references:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4-src.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js
Changed to:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js
Note that it worked with both versions of OpenLayers js file but not when using 2.5.0.
Thanks to Ian and Mike for helping!
Ok, I figured out my issue. I looked at the post Mike shared Using Proj4js in Openlayers - Proj4js is not defined and tried the example code in my project which still failed. That narrowed it down to the js references. So I copied the references and et voila; success!
My references:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4-src.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.12/OpenLayers.min.js
Changed to:
https://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js
https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js
Note that it worked with both versions of OpenLayers js file but not when using 2.5.0.
Thanks to Ian and Mike for helping!
answered May 22 at 15:17
Simon JeffsSimon Jeffs
111
111
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
add a comment |
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
2..5.0 is working for me. I've added the code to my answer.
– Mike
May 22 at 16:23
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
Working with mine now too. Thanks Mike!
– Simon Jeffs
May 23 at 10:46
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f323552%2fusing-proj4js-with-openlayers-to-transform-lat-lng-from-4326-to-27700-but-coming%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown