This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How can I convert a location to lat/long in jquery?

0

HI,

I want to convert location to lat/long in jquery.

Thanks, Vivek

asked 28 Oct '10, 13:14

Vivek%20Kumar's gravatar image

Vivek Kumar
15345
accept rate: 0%

edited 01 Nov '10, 23:06

TomH's gravatar image

TomH ♦♦
3.3k83943

1

Can you detail your need and your context, please.

(28 Oct '10, 15:52) frodrigo

Hi, I have two text box called from and to and I am inserting location in it. Suppose from text box has France and to text box england, now I want to convert from location to latitude /longitude and as well as to location to latitude and longitude. how we can do that.

I want to do in j query. Thanks for your reply.

(28 Oct '10, 16:57) Vivek Kumar

2 Answers:

1

The Osm.org Routing Demo does exactly this by sending a JSONP request to Nominatim. You can grab a tarball and look in yours.js.

If Nominatim returns more than one result, the first one is used. It has a number of drawbacks. For example, when searching for a large city, the first result may be a border that is quite far from the actual city center.

answered 31 Oct '10, 23:22

Nic%20Roets's gravatar image

Nic Roets
58391219
accept rate: 6%

edited 01 Nov '10, 00:37

0

Your problem is called geocoding and there are various tools and APIs which can help you with that. You could use Nominatim, I guess, or see e.g. Yahoo! PlaceFinder.

answered 28 Oct '10, 17:13

Mormegil's gravatar image

Mormegil
3014
accept rate: 0%

Hi ,thanks for the reply

Do you have any example related to open layer.

(29 Oct '10, 10:21) Vivek Kumar

Source code available on GitHub .