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 7368491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:41:22+00:00 2026-05-29T03:41:22+00:00

I am currently using the google maps api to geocode locations on the map

  • 0

I am currently using the google maps api to geocode locations on the map and return the address of the street.

I currently return the address with the following code:

        function codeLatLng(markerPos) {
            geocoder.geocode({'latLng': markerPos}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                //Set markerAddress variable
                var markerAddress = results[0].formatted_address;
alert(markerAddress);
...

But what if I don’t want to return the formatted address but a more detailed version using Address Component Types, how can I return certain address values like: http://code.google.com/apis/maps/documentation/geocoding/#Types

Help appreciated.

  • 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-29T03:41:24+00:00Added an answer on May 29, 2026 at 3:41 am

    May I ask, why are you checking for results[1] and then using results[0] (or is it just a typo I should ignore)?

    As long as status is OK, there will be at least one result.
    Otherwise, status would be ZERO_RESULTS.

    Anyway, you can use something like this:

    function codeLatLng(markerPos) {
      geocoder.geocode({'latLng': markerPos}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          var markerAddress = results[0].address_components[0].long_name
              + ' (type: ' + results[0].address_components[0].types[0] + ')';
          alert(markerAddress);
    

    You can play a lot with the whole address_components array, have fun! 🙂

    For even more fun, have a look at the (source code of the) Google Maps API v3 Geocoder Tool at http://gmaps-samples-v3.googlecode.com/svn/trunk/geocoder/v3-geocoder-tool.html

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

Sidebar

Related Questions

I am currently using the google maps' reverse geocoding API to convert long/lat received
using javascript google-maps api I currently have it setup to remove a maker I
I am developing a gis application using Google maps API. Currently I am using
I'm trying to create map (using the Google Maps JavaScript API V3 ) which
I'm currently working on an ASP.NET project where I'm using the Google Maps API
I am using the Google Maps v3 API . I currently am making a
I'm using Google Maps API to display a map and some markers on it.
I am using google maps api v3. In my map the current position name
I have an application which is currently using the google map API. I like
NOTE: I'm using v3 of the Google Maps API I'm trying to add an

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.