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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:38:44+00:00 2026-06-17T04:38:44+00:00

I have the following code: function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(start,showError); } else{

  • 0

I have the following code:

     function getLocation()
                {
                if (navigator.geolocation)
                  {
                  navigator.geolocation.getCurrentPosition(start,showError);

                  }
                else{
                error('Geo Location is not supported');
                }
                }

 function start(position) {

                var mySearch = document.getElementById("search").value;           
               var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

                map = new google.maps.Map(document.getElementById('map'), {
                  mapTypeId: google.maps.MapTypeId.ROADMAP,
                  center: latlng,
                  zoom: 12
                });

                var request = {
                  location: latlng,
                  radius: 500,
                  query: mySearch
                };

                 infowindow = new google.maps.InfoWindow();
                 service = new google.maps.places.PlacesService(map);
                 service.textSearch(request, callback);
                }

                function callback(results, status) {

                  if (status == google.maps.places.PlacesServiceStatus.OK) {
                    for (var i = 0; i < results.length; i++) {
                      var place = results[i];
                      createMarker(results[i]);

                    }
                  }
                }


              function createMarker(place) {

                var placeLoc = place.geometry.location;
                var marker = new google.maps.Marker({
                  map: map,
                  position: place.geometry.location,


                });

                google.maps.event.addListener(marker, 'click', function() {
                  infowindow.setContent(place.name, place.website);
                  infowindow.open(map, this);
                });
              } 

The code works fine however I am trying to retrieve more details about a place. I know about the place details at: https://developers.google.com/maps/documentation/javascript/places#place_details I’m just unsure where and how to adjust my code to say add in the places website. I’m struggling to work out where to get the reference and then how to use it. If someone could write it within my code that would be great.

  • 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-17T04:38:46+00:00Added an answer on June 17, 2026 at 4:38 am

    Adjusted “createMarker” function (not tested):

    function createMarker(place) {
        var placeLoc = place.geometry.location;
        if (place.icon) {
          var image = new google.maps.MarkerImage(
                place.icon, new google.maps.Size(71, 71),
                new google.maps.Point(0, 0), new google.maps.Point(17, 34),
                new google.maps.Size(25, 25));
        } else var image = null;
    
        var marker = new google.maps.Marker({
          map: map,
          icon: image,
          position: place.geometry.location
        });
        var request =  {
          reference: place.reference
        };
    
        google.maps.event.addListener(marker,'click',function(){
            service.getDetails(request, function(place, status) {
              if (status == google.maps.places.PlacesServiceStatus.OK) {
                var contentStr = '<h5>'+place.name+'</h5><p>'+place.formatted_address;
                if (!!place.formatted_phone_number) contentStr += '<br>'+place.formatted_phone_number;
                if (!!place.website) contentStr += '<br><a target="_blank" href="'+place.website+'">'+place.website+'</a>';
                contentStr += '<br>'+place.types+'</p>';
                infowindow.setContent(contentStr);
                infowindow.open(map,marker);
              } else { 
                var contentStr = "<h5>No Result, status="+status+"</h5>";
                infowindow.setContent(contentStr);
                infowindow.open(map,marker);
              }
            });
        });
    }
    

    working example

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

Sidebar

Related Questions

I have the following code: <script type = text/javascript> function getLocation() { if (navigator.geolocation)
I have the following JavaScript code: <script type='text/javascipt' language=javascript> function getUserLoc() { if (navigator.geolocation)
Hi all I have the following code: var map; var infowindow; function getLocation() {
I have the following code function randomizer(start, end) { return Math.floor((end - start) *
I have an issue with window.navigator, I'm getting error code 1, User denied Geolocation
I have the following code: function get_login() { hideshow('loading2',1); error(0); $.ajax({ type: POST, url:
I have the following function that checks if the browser supports geo-location and then
I have the following code: function isValidAuthor($authorID){ $query = SELECT * FROM jos_users WHERE
I have the following code: function build_all_combinations(input_array){ array = [1,2,3] limit = array.length -
I have the following code: function Person(){ this.age = 30; } function Stats(){ this.age

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.