?
Solved

How do I translate the Google maps v3 Geocode location_type to a Geocode score 0-9?

Posted on 2013-01-06
4
Medium Priority
?
1,908 Views
Last Modified: 2013-01-06
Hi,

I am going through the process of converting from Google v2 Maps API to v3 Maps API. A problem that I have encountered is that a Geocode score (0-9) is not used by the V3 API.

Instead the API uses (geometry.location_type) which will return either ROOFTOP, GEOMETRIC_CENTER, RANGE_INTERPOLATED or APPROXIMATE. I can also use (google.maps.GeocoderStatus.OK) to see if an address can actually be Geocoded.

Our back office systems and IOS App are programmed to work off a (0-9) score I could go through and update them all but that would be rather time consuming. I am wondering if anyone has any idea as to how the string returned by (geometry.location_type) can be converted to a (0-9) score maybe by a case statement or something like that?

If anyone has any better ideas or I am over complicating this please let me know.

I guess what I am looking for is how to interpret the string returned by (geometry.location_type) as a number that resembles the v2 API Geocode score from 1 to 9 as closely as possible. The programming is not hard the interpretation of the string to a Geocode number score is the tricky part.

Thanks to anyone who can help.
0
Comment
Question by:jwleys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 

Author Comment

by:jwleys
ID: 38749280
Reference V3 API method:
https://developers.google.com/maps/documentation/javascript/geocoding

location_type stores additional data about the specified location. The following values are currently supported:

- google.maps.GeocoderLocationType.ROOFTOP indicates that the returned result reflects a precise geocode.

- google.maps.GeocoderLocationType.RANGE_INTERPOLATED indicates that the returned result reflects an approximation (usually on a road) interpolated between two precise points (such as intersections). Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.

- google.maps.GeocoderLocationType.GEOMETRIC_CENTER indicates that the returned result is the geometric center of a result such as a polyline (for example, a street) or polygon (region).

- google.maps.GeocoderLocationType.APPROXIMATE indicates that the returned result is approximate.
0
 

Author Comment

by:jwleys
ID: 38749287
Reference V2 API method:
https://developers.google.com/maps/documentation/geocoding/v2/

0 = Unknown accuracy.
1 = Country level accuracy.
2 = Region (state, province, prefecture, etc.) level accuracy.
3 = Sub-region (county, municipality, etc.) level accuracy.
4 = Town (city, village) level accuracy.
5 = Post code (zip code) level accuracy.
6 = Street level accuracy.
7 = Intersection level accuracy.
8 = Address level accuracy.
9 = Premise (building name, property name, shopping center, etc.) level accuracy.
0
 

Accepted Solution

by:
jwleys earned 0 total points
ID: 38749419
//Possible solution JavaScript Case Statement bit of a hack would like to a second opinion:
if (status == google.maps.GeocoderStatus.OK) {
   switch(results[0].geometry.location_type){
      case "ROOFTOP":
         geo_score = 9;
      break;

      case "RANGE_INTERPOLATED":
         geo_score = 7;
      break;

      case "GEOMETRIC_CENTER":
         geo_score = 6;
      break;
   
      case "APPROXIMATE":
         geo_score = 4;
      break;
   }
}else{
   geo_score = 0;
}
0
 

Author Closing Comment

by:jwleys
ID: 38749530
It's a hack but it works and seems to do the job just fine.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question