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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:40:12+00:00 2026-05-27T11:40:12+00:00

I am trying to make a website using Google API V3 to show your

  • 0

I am trying to make a website using Google API V3 to show your current location and nearby restaurants or cafes..
I tried this code on google’s tutorial but i cant get that this api will show my current position on the map
here is the code:
there is a pyrmont and i can change it with another latitude and longitude but i could not make it useful with navigator.geolocation.getCurrentPosition();
Thanks

AND i know there is this code: but i dont know how to use the get position out of it…

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>

<script type="text/javascript">
  var map;
  var infowindow;

if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(success, error);
    } else {
      alert('geolocation not supported');
    }

    function success(position) {
      alert(position.coords.latitude + ', ' + position.coords.longitude);
    }

    function error(msg) {
      alert('error: ' + msg);
    }

  function initialize() {
    var pyrmont = new google.maps.LatLng(48.195201,16.369547);

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

    var request = {
      location: pyrmont,
      radius: 500,
      types: ['cafe']
    };
    infowindow = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService(map);
    service.search(request, callback);
  }

  function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; 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);
      infowindow.open(map, this);
    });
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>
  • 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-27T11:40:13+00:00Added an answer on May 27, 2026 at 11:40 am

    EDITED.

    So, the search function was returning zero results on my actual location, so when I offset my actual location to be closer to your original (since I don’t know the density of results matching your query) it works for me. You’ll have to edit the 6.6 and 89.45 to see it work, but then you’ll need to do something with the search itself if you want it to be useful

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style>
    #map_canvas{width:500px;height:500px;}
    </style>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
    <script type="text/javascript">
      var map;
      var infowindow;
    
      function initialize(position) {
        //var pyrmont = new google.maps.LatLng(48.195201,16.369547);
        var pyrmont = new google.maps.LatLng(position.coords.latitude+6.6,position.coords.longitude+89.45);
        map = new google.maps.Map(document.getElementById('map_canvas'), {
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: pyrmont,
          zoom: 15
        });
        var a = new google.maps.Marker({position: pyrmont,map: map,icon:'http://www.blind-summit.co.uk/wp-content/plugins/google-map/images/marker_blue.png'});
        var request = {
          location: pyrmont,
          radius: 500,
          types: ['cafe']
        };
        infowindow = new google.maps.InfoWindow();
        var service = new google.maps.places.PlacesService(map);
        service.search(request, callback);
      }
    
      function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
          for (var i = 0; i < results.length; i++) {
            createMarker(results[i]);
          }
        }
        if (status == google.maps.places.PlacesServiceStatus.ZERO_RESULTS){
       alert('zero results near this location');
        }
      }
    
      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);
          infowindow.open(map, this);
        });
      }
    
      google.maps.event.addDomListener(window, 'load', function(){
          navigator.geolocation.getCurrentPosition(initialize);
      });
    </script>
    </head>
    <body>
    <div id="map_canvas"></div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a program using java to access this website by inserting
I am trying to make a website using Java on google app-engine. Can you
I'm trying to make a Google Maps widget for my website but all of
i am trying to understand this google social graph api a bit and i
I'm trying to make a website using Dreamweaver. I'd like to have a page
I'm trying to make a google chrome extension using javascript/html. Currently, I'm simply trying
am currently using google feed api to get feed links dynamically. am trying to
Hey i'm trying to make my website delete a file using the unlink(); function.
HI all, i'm trying to use google chart API to make some charts in
I'm trying to make a blog entry programmatically using this code. $node->title = $_POST['title'];

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.