Search code examples
javascripthtmlgoogle-maps-api-2

lat and long with submit button


I'm and intern at an company that has asked me to put some markers on a google maps. I did this with the lat and long since geocoding the addresses and than making markers out of that would take to long to load.

However, they now also asked if I could make an easy application to get the lat and long from addresses. So a simple geocoding app:

One input field and a submit button, when clicked on the button the lat and long will show up below or above or next to it.

Which function can i use to get this?

I've been looking on the internet for a few days now, but I can't find anything that also makes it so that i can show the lat and long that was found.

I'm not very good at programming.


Solution

  • Im confused, are you trying to find the lat and lng of an address?

    if so use google maps api http://code.google.com/apis/maps/documentation/geocoding/

    here is an example http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true

    and that will spit back the lat and lng in a json format.

    If you want to reverse geocode something http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

    To make an app that does it with a submit button, use jquery/ajax and pull the result from googles service.