views:

36

answers:

3

how i can get latitude from a city name like Florida how i can get the latitude and longitude from sending a json to google map api.

any way to do this.

i need a sollution in javascript or jquery through the json.

A: 

Not sure what you mean when you say send json but you can do it with this function:

function getLatLong(address){
      var geo = new google.maps.Geocoder;

      geo.geocode({'address':address},function(results, status){
              if (status == google.maps.GeocoderStatus.OK) {
                return results[0].geometry.location;
              } else {
                alert("Geocode was not successful for the following reason: " + status);
              }

       });

  }

that will return an object which you can reference with .lat() and .lng() to get the latitude and longitude.

Thomas Clayson
please read my answer to solve a another issue in this case.
zinka
A: 

hello thomas thanks for help me but i need a thing more

when i run the code he tell me (27.19, 78.01) but i need a position too like EAST , WEST

how i can get them in format (27.19, 78.01E) instead for (27.19, 78.01).

E for EAST
zinka
Please add Comments and not answers for Comments.
Ardman
i know that but it is unclear in comment so i use it. it can be clear the language of mine.
zinka
The answers go from -180 to 180. Anything <0 (eg: -10) will be West. Anything >0 will be East. Please add rep or mark as an answer if I've helped you. :)
Thomas Clayson
A: 

@thomas you are right.

the definition is

West south are also nagative

North East are also positive.

zinka