Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does autolink:map work

I am using antroid:autoLink="map" attribute of TextView to Go to map and find the address associated with that textview.

But its is behaving stragely and finding only some addresses. Here is the code what I am trying:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView
        android:id="@+id/textViewautoLink"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/autolinktext"
        android:autoLink="map"></TextView>
</LinearLayout>

Here is my strings.xml

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="autolinktext">1600 Amphitheatre Parkway, Mountain View, CA 94043 </string>
</resources>

Issue is:

Suppose I am writing the above string i.e. 1600 Amphitheatre Parkway, Mountain View, CA 94043 then its working fine and textView gets blue in colour and when I click onit it searches the address on Map.

When I change this address to : 1600 Amphitheatre Parkway, Mumbai, IN then also it shows the same thing and tries to search the address but since the address is wrong it couldnt find it. Its OK.

But when I write other address like: 600 Band Stand, Mumbai, IN Then

1) the textview isnt in blue color

2) Its doesn't seem to be clickable

3) and since it is not clickable it doesn't find the address.

I am searching google but am not getting any reason for this behaviour. Also I want to know that

Is there any format for writing this map address?

Also how android knows that the address is valid or not by just writing the address in String as I have written the same address in the same format just changed the String and the result is that one address is clickable and other is not.

Please Help.

like image 888
Maverick Avatar asked Jan 07 '12 05:01

Maverick


1 Answers

Below is the comment picked from the matcher

  1. look for a 1 - 5 digit number for a street number (no support for 'One Microsoft Way')
  2. ignore if preceded by '#', Suite, Ste, Rm
  3. look for two or more words (up to 5? North Frank Lloyd Wright Blvd)
    note: "The Circle at North Hills St." has six words, and a lower 'at' -- allow at, by, of, in, the, and, ... ?
  4. if a word starts with a lowercase letter, no match
    allow: , . - # / (for 1/2) ' "
  5. look for one or two delimiters to represent possible 2nd addr line and city name
    look for either full state name, or state two letters, and/or zip code (5 or 9 digits)
  6. now look for street suffix, either in full or abbreviated form, with optional 's' if there's an asterisk

Source : CacheBuilder.cpp. For further info you could check the exact algorithm in CacheBuilder::FindPartialAddress of webviewcore

As far as i see from code only street names ending in LleY , NneX, RCade, VEnue, LAMEDA, aYoU and so on ... are matched. In your case Band stand does not match the street name ending that is common in US

like image 134
nandeesh Avatar answered Oct 11 '22 14:10

nandeesh