1
votes

I have use the code given below, please copy and paste in your URL, which gives latitude and longitude of a specific place.

But when I have used the same call with wrong place it returns latitude and longitude. How to check whether it is right and wrong?

  1. http://maps.google.com/maps/api/geocode/json?address=dubai+United+Arab+Emirates&sensor=false

  2. http://maps.google.com/maps/api/geocode/json?address=anu+India&sensor=false

Thanks

1

1 Answers

2
votes

A typical scenario for using geocoding will be when you know that the address exists and you want to get the location coordinates, maybe to mark on a map. When you search an address in google geocoding api, it will find exact matches and also partial matches to correct for cases like spelling mistakes or multiple spellings in use. Due to partial match, when you search for a word, words close to that in terms of the letters used and the number of letters present will also be found. You can explore 2 options to refine the results:

1, If you want to avoid partial matches , you can try component filtering , where you specify filters on components like locality, country , etc and only exact matches will be returned.

2, You can process the json result in your code by retreiving different components and doing comparisons and taking only cases matching your requirement.