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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:05:48+00:00 2026-06-03T02:05:48+00:00

I need to get address and coordinates after clicking on the map, I’m using

  • 0

I need to get address and coordinates after clicking on the map, I’m using google map api v3, i recuperated the coordinates in inputs but i need also arddress of the point.

 function initialize() {
            var myOptions = {
                center: new google.maps.LatLng(36.835769, 10.247693 ),
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);
            google.maps.event.addListener(map, 'click', function(event) {
                placeMarker(event.latLng);
            });

            var marker;
            function placeMarker(location) {
                if(marker){ //on vérifie si le marqueur existe
                    marker.setPosition(location); //on change sa position
                }else{
                    marker = new google.maps.Marker({ //on créé le marqueur
                        position: location, 
                        map: map
                    });
                }
                latitude.value=location.lat();
                longitude.value=location.lng();
            }

        }

I used this php script to get the address but if don’t know how to use it in javascript?
Can i use javascript to get address?

<?php
    $url      = 'http://where.yahooapis.com/geocode?location=40.714224,-73.961452&gflags=R&flags=J';
    $response = json_decode(file_get_contents($url));
    $location = $response->ResultSet->Results[0];
    foreach ((array) $location as $key => $value) {
            if($key == 'city')
                $city = $value;
            if($key == 'country')
                $country = $value;
            if($key == 'street')
                $street = $value;
    }
    echo "Street: ".$street."<br>";
    echo "City: ".$city;
    echo "<br/>Country: ".$country;

    ?>
  • 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-06-03T02:05:50+00:00Added an answer on June 3, 2026 at 2:05 am

    Here’s a simple example of retrieving the address. The results can get complicated (it is an array, from what I saw it’s an arbitrary mix of cross streets, neighborhoods, state, and country. I didn’t see a pattern)

    I am only using the first line of results which is a combination of street, city, state, country. Read here the details:

    https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingResults

    A demo is here: http://jsfiddle.net/eB2RX/1/

    I noticed the resolution is not very good, I mean, in the USA you get street numbers but not in Tunisia. I only saw Street names.

    Part of the code:

      var map;
      var geocoder;
      var mapOptions = { center: new google.maps.LatLng(0.0, 0.0), zoom: 2,
        mapTypeId: google.maps.MapTypeId.ROADMAP };
    
      function initialize() {
            var myOptions = {
                center: new google.maps.LatLng(36.835769, 10.247693 ),
                zoom: 15,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
            geocoder = new google.maps.Geocoder();
            var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);
            google.maps.event.addListener(map, 'click', function(event) {
                placeMarker(event.latLng);
            });
    
            var marker;
            function placeMarker(location) {
                if(marker){ //on vérifie si le marqueur existe
                    marker.setPosition(location); //on change sa position
                }else{
                    marker = new google.maps.Marker({ //on créé le marqueur
                        position: location, 
                        map: map
                    });
                }
                document.getElementById('lat').value=location.lat();
                document.getElementById('lng').value=location.lng();
                getAddress(location);
            }
    
      function getAddress(latLng) {
        geocoder.geocode( {'latLng': latLng},
          function(results, status) {
            if(status == google.maps.GeocoderStatus.OK) {
              if(results[0]) {
                document.getElementById("address").value = results[0].formatted_address;
              }
              else {
                document.getElementById("address").value = "No results";
              }
            }
            else {
              document.getElementById("address").value = status;
            }
          });
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function to get an nearest address or city from coordinates(lat,long) using
I'm using Delphi and need to get the current Windows DNS server IP address
I need to get the host example.com from an e-mail address like user@example.com using
I need to get Image object from Google Maps, centered to a given address,
I need get the IP address for the user cross the proxy using PHP...
I need to get a requested host's ip address using urllib2 like: import urllib2
i need grab to internet explorer address bar. how to get address bar url
i need grab to firefox address bar. how to get address bar url for
I need to get the actual local network IP address of the computer (e.g.
I need get position element in table. But function position() returns me to the

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.