Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:14:16+00:00 2026-05-28T13:14:16+00:00

Using V3 of the google maps API, is there any reliable way to format

  • 0

Using V3 of the google maps API, is there any reliable way to format addresses with the line break? By this, I mean something like 1600 Amphitheatre Parkway Mountain View, CA 94043 should be formatted as

1600 Amphitheatre Parkway
Mountain View, CA 94043

Looking through the response object from geocoding, there is an address_components array that has, for the above address, 8 components (not all of the components are used for the address):

0: Object
    long_name: "1600"
    short_name: "1600"
    types: Array[1]
        0: "street_number"
        length: 1
1: Object
    long_name: "Amphitheatre Pkwy"
    short_name: "Amphitheatre Pkwy"
    types: Array[1]
        0: "route"
        length: 1
2: Object
    long_name: "Mountain View"
    short_name: "Mountain View"
    types: Array[2]
        0: "locality"
        1: "political"
        length: 2
3: Object
    long_name: "San Jose"
    short_name: "San Jose"
    types: Array[2]
        0: "administrative_area_level_3"
        1: "political"
        length: 2
4: Object
    long_name: "Santa Clara"
    short_name: "Santa Clara"
    types: Array[2]
        0: "administrative_area_level_2"
        1: "political"
        length: 2
5: Object
    long_name: "California"
    short_name: "CA"
    types: Array[2]
        0: "administrative_area_level_1"
        1: "political"
        length: 2
6: Object
    long_name: "United States"
    short_name: "US"
    types: Array[2]
        0: "country"
        1: "political"
        length: 2
7: Object
    long_name: "94043"
    short_name: "94043"
    types: Array[1]
        0: "postal_code"
        length: 1

I was thinking that you could just combine parts that you want, like

sprintf("%s %s<br />%s, %s %s",
        array[0].short_name,
        array[1].short_name,
        array[2].short_name,
        array[5].short_name,
        array[7].short_name)

[edit]I just realized that sprintf isn’t defined by default in JavaScript, so just a concatenation would do I guess.[/edit]

But that seems awfully unreliable. Does anyone know the details on the structure of address_components, and if it’s reliably similar like that for street addresses in the US? If I wanted to, I guess I could look for the proper types (street_number,route, etc) as well.

I’d love it if anyone had a better way than what I”m doing here…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:14:17+00:00Added an answer on May 28, 2026 at 1:14 pm

    Or…. (again, assuming US addresses)… there are CASS-Certified services which will do it for you. For example, I work for a company called SmartyStreets and we do address verification. Google, on the other hand, does address approximation and not all the results you get will be accurate; it makes best guesses. CASS-Certified software is going to be reliable and accurate.

    The LiveAddress API returns results from a simple REST request. Here’s a snippet of the JSON result of the address you used above:

     "delivery_line_1":"1600 Amphitheatre Pkwy",
     "last_line":"Mountain View CA 94043-1351"
    

    So here it’s automatically been standardized and correctly delimited by line breaks for you. I think you will find it to be of some use (plus, it’s free). Let me know if you have any questions; I’ll assist you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any possibility to highlight a street using the Google Maps API? I
Update II I Figured this out. When using google maps api, the model must
I'm using Google maps api v3. In the middle of the map there is
Is anyone out there using a timeout on with the google maps API? I
I just started working using Google Maps API yesterday, and trying to set up
All the examples I've come across using Google Maps API seem to show a
It seems that licensing terms would prevent us from using Google Maps API in
Using the Google Maps API, how can I get the latitude and longitude of
Using the Google Maps API v3: How do I change the mouse cursor when
We're using the Google Maps API for an application to determine distance and driving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.