I have two text fields - one displaying the [street_address] and the other displaying the [formatted_address]. No matter what address I enter, the values in these fields are identical. Is this by design? For display purposes, does it make any difference which token I use? And lastly, is there a token that captures just the street address - without the city, state, zip and country?

As a side note: I just discovered OL and these modules yesterday - as I was searching for alternative methods to track and search by location for multiple content types. This is the most exciting discovery I've made in Drupal land since I started my Drupal development journey about 6 weeks ago. Great stuff!

Comments

joshuabud’s picture

The [formatted_address] provided the full address which includes all information returned aside from the name of the location, and the [street_address] only gave the actual number within the returned results. If you would like to break down the address into multiple fields this would achieve the functionality you mention I believe which is an address field without city, state, zip, and country.

When creating the content type breakdown the address fields individually as a CCK field so you would have Street[stree_address], City[locality], State[administrative_area_level_1], Zip[postal_code].

It took me a bit to figure out that in order to break down the fields on the Geocoder widget field settings I had to first create each of the individual fields and then change the settings. After I figured that out and the auto-complete(requires the dev version) it was all downhill from there for the implementation on a per node map content.

joshuabud’s picture

After further usage of this functionality I'm also having the issue of full address being auto-completed when using only [street_address] which it should only be the street number, and name not to include the city, state, zip info.

joshuabud’s picture

Version: 6.x-2.0-alpha5 » 6.x-2.x-dev
Component: Documentation » Code
Category: support » bug
Priority: Normal » Major

I'm upgrading this from a support issue to a bug as there is no solution to fixing the issue. I am curious as to whether or not this could be related to using Google Maps as opposed to say OSM. I wonder if Google Maps geo information has a different token for producing just a [street_address] other than what is being requested.

I have tried editing the code in a couple of places but it didn't fix the issue so I can't provide a patch.

I am currently using dev versions of both Openlayers and Openlayers_Geocoder, and my map layer is using Google normal maps as the base.

My fields include:

Search Address - Openlayers Geocoder Field
Address - Tokenized as [street_address] - Populates full [formatted_address]
City - Tokenized as [locality] - Works as expected.
State - Tokenized as [administrative_area_level_1] - Works as expected.
Zip - Tokenized as [postal_code] - Works as expected

francewhoa’s picture

@JoshuaBud: Thanks for your comment in #1. I wrote a tutorial at http://drupal.org/node/1002852

scalp’s picture

Also having this issue. Would be great if it were possible to parse out the street number along with street name only as [street_address]. Tried playing with openlayers_geocoder.token.inc, but couldn't get it to work. For now using [street_number] [route] works.

Dave-B’s picture

Subscribe

bsnodgrass’s picture

In addition to a token for street address which would populate a number and street name, it would be very beneficial to have only street name. I have a requirement on a project to create not only "official" street names but also an alias. The application for this is to allow for a "common" name to be used to search an official list while records are saved with the "official" name as well as the geocoded coordinates.

Great module by the way!

tobstare’s picture

It's not an issue of Openlayers Geocoder. The values are given by Google, so you only have to follow the code that is given by google and use those tokens:
[route] [street_number]
to get a Streetname with the housenumber.

rootwork’s picture

In order to get a "street address" in its common parlance (i.e. the second line when you write an address) I use these tokens:

[street_number] [route] [post_box] [floor] [room]

That covers everything that might be included on that line, under any normal circumstances.

However, this doesn't answer the OP's original question about the difference between the tokens [street_address] (which is the complete address, not just the street address "line") and [formatted_address]. I Googled around but couldn't find a listing of current Google Geocoding values (I found some from v1 and v2 but nothing current) so I guess the question is unresolved.

steinmb’s picture

Category: bug » support
Priority: Major » Normal

Trying to learn this module so I did some digging.

Result from maps.google.com

Searching for "2828 SW Corbett Ave, Portland, Oregon 97201, USA" (The Drupal Association address)

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "2828",
               "short_name" : "2828",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "SW Corbett Ave",
               "short_name" : "SW Corbett Ave",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Corbett - Terwilliger - Lair Hill",
               "short_name" : "Corbett - Terwilliger - Lair Hill",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Portland",
               "short_name" : "Portland",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Multnomah County",
               "short_name" : "Multnomah County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Oregon",
               "short_name" : "OR",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "USA",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "97201",
               "short_name" : "97201",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "2828 SW Corbett Ave, Portland, Oregon 97201, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 45.50240880,
                  "lng" : -122.67550470
               },
               "southwest" : {
                  "lat" : 45.50240880,
                  "lng" : -122.67550570
               }
            },
            "location" : {
               "lat" : 45.50240880,
               "lng" : -122.67550470
            },
            "location_type" : "RANGE_INTERPOLATED",
            "viewport" : {
               "northeast" : {
                  "lat" : 45.50375778029150,
                  "lng" : -122.6741562197085
               },
               "southwest" : {
                  "lat" : 45.50105981970850,
                  "lng" : -122.6768541802915
               }
            }
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}

Lines from openlayers_geocoder.token.inc

<?php
$tokens['formatted_address'] = $object['address'];
// Keep v2 tokens for backward compatibility
$tokens['address'] = $object['components']['street_address'] ? $tokens['street_address'] : '';
?>

To to me is this just a backward compatibility token from back Google ver. 2.x.