1

Hi Folks

I'm trying to create a map based on a tutorial I found. The tutorial has a piece of code for the start point;

// define point as a new LonLat object and transfom point = new OpenLayers.LonLat(-4.225, 57.478); point.transform("EPSG:4326", "EPSG:3857");

I can follow what this code does but it centers the map in Scotland. I'm looking to center it in Dublin. In Google Earth the coordinates I want are 53.285756, -6.141998. But when I put that in, OpenStreetMap sends me to somewhere near the Seychelles. Can you help with how I can convert it correctly? I'm a beginners so apologies if I've not explained it correctly. Thanks.

asked 02 Apr '17, 11:24

Shane_Ire's gravatar image

Shane_Ire
26112
accept rate: 0%

1

Perhaps you could explain a little more fully what it is you're trying to do when you say "create a map."

Which program or website are you plugging the coordinates into?

When I put 53.285756, -6.141998 into JOSM, the OSM editor program, it takes me to a golf course in Dublin, so the coordinates are reasonably accurate.

Cheers

Dave

(02 Apr '17, 11:42) AlaskaDave

Hi Dave

I'm only just learning Web based GIS. So here are the details. I have GeoServer 2.8.2 hosted on a VM. It is also the webserver. I have a simple HTML page calling OpenLayers and a .js file.

<script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script type="text/JavaScript" src="map.js"></script>

In the .js file I am using OpenLayer and OSM;

//create new map object map = new OpenLayers.Map("mymap");

//create new OSM base layer
osmlayer = new OpenLayers.Layer.OSM("Open Street Map");

//create WMS layers

When I enter this code and open the page via http://localhost:8080/geoserver/www/index.html. It opens off the coast of Africa.

// define point as a new LonLat object and transform point = new OpenLayers.LonLat(53.285756, -6.141998); //point.transform("EPSG:4326", "EPSG:3857");

As I say, I'm new to this so might not be explaining it well. Thanks

(02 Apr '17, 12:08) Shane_Ire
1

Thanks for the information. This list is watched by many smart OSM folks who can possibly help and I'm sure you'll get some answers shortly. But I'm afraid I can't be of much help because I have no expertise in the area you're addressing.

Best,

Dave

(02 Apr '17, 12:15) AlaskaDave

Are you mixing up latitude and longitude? OpenLayers.LonLat() requires longitude first, then latitude (as the name of the function already indicates).

(02 Apr '17, 14:22) scai ♦

Thanks Dave, sorted it. Had to clear out Internet cache.

(02 Apr '17, 14:32) Shane_Ire

For Info i cut and paste your coords in OSMs search box and got this http://www.openstreetmap.org/search?query=53.285756%2C%20-6.141998#map=16/53.2858/-6.1420

(02 Apr '17, 16:01) andy mackey
showing 5 of 6 show 1 more comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×294
×122
×24

question asked: 02 Apr '17, 11:24

question was seen: 2,912 times

last updated: 02 Apr '17, 16:01

powered by OSQA