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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:51:03+00:00 2026-06-17T19:51:03+00:00

var myloc; function initialize() { if (navigator.geolocation) navigator.geolocation.getCurrentPosition(function(pos) { var me = new google.maps.LatLng(pos.coords.latitude,

  • 0
var myloc;
function initialize() {

  if (navigator.geolocation) navigator.geolocation.getCurrentPosition(function(pos) {
    var me = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
    myloc.setPosition(me);
    myloc.setMap(map);
  }, function(error) {
      // ...
  });

  var mapOptions = {
    zoom: 14,
    center: me,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  var mylocOptions = {
    title: "You are here..."
  };

  var map = new google.maps.Map(document.getElementById("map_canvas"), 
      mapOptions);

  myloc = new google.maps.Marker(mylocOptions);
}

I checked out another question and feel like I got somewhere with this. When I open the app (the first time) it asks me for permission to use my location. I think I simplified the myloc options, I’m fine with the default look and everything of the marker for testing. Upon allowing it, nothing happens, though. me is undefined. Maybe I’m doing something in the wrong order?

Without the location, I am able to get the map up with other markers, so… it’s gotta be an order thing? I’ve tried a few variations…

I’d like to eventually plop a marker onto the map after the browser gives up the general coordinates. Eventually that will be movable and updated in the db, but I’m not worried about that just yet, obviously. Baby steps…

  • 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-17T19:51:04+00:00Added an answer on June 17, 2026 at 7:51 pm

    Don’t set your marker’s position to me when you first initialize it. Because me is available after the user allows the browser to use their location. Do it when you get their location.

    var mylocOptions = {
      title: "You are here..."
    };
    
    if (navigator.geolocation) navigator.geolocation.getCurrentPosition(function(pos) {
      var me = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
      myloc.setPosition(me);
      myloc.setMap(map);
      map.setCenter(me);
    }, function(error) {
      // ...
    });
    

    also remove

    center: me
    

    where you define map.

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

Sidebar

Related Questions

var ref1 = new Firebase(http://gamma.firebase.com/myuser/123,456); ref1.set(123,456); var on1 = ref1.on(value, function(snapshot) { console.log(snapshot.val()); });
var request = new Request({ method: 'get', url: 'onlinestatusoutput.html.php', onComplete:function(response) { $('ajax-content').get('tween', {property: 'opacity',
var name = new Array('freddy', 'mac', 'fanny', 'may'); var content = 'hi '.+name[i]+.'!'; $('div.class').each(function
I have the following JavaScript code: <script type='text/javascipt' language=javascript> function getUserLoc() { if (navigator.geolocation)
var object = {}; // Global Object (function() { var theArg, google, yahoo; object.google
var Foo = Foo || {}; Foo.Controller = (function ($) { var $page =
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
var stage = new Kinetic.Stage({ container: 'container', width: 578, height: 200 }); var layer
var sgt1 = Backbone.Collection.extend({ model: sgt2 }); var a = new sgt1(); a.add({attr1: 'asd'});
var counter = 5; var timer = setInterval(function () { seconds--; $('#regmsg').html('Successful! Message will

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.