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

  • Home
  • SEARCH
  • 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 7966501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:26:40+00:00 2026-06-04T06:26:40+00:00

What i am trying to do is adding a marker when the geocoder is

  • 0

What i am trying to do is adding a marker when the geocoder is done parsing to latlng… This is my code:

function parseLocation() {
    var user1Location = "Mechelen, Belgium";
    var geocoder = new google.maps.Geocoder();
    //convert location into longitude and latitude
    geocoder.geocode({
        address: user1Location
    }, function (locResult) {
        lat1 = locResult[0].geometry.location.lat();
        lng1 = locResult[0].geometry.location.lng();
        if (status == google.maps.GeocoderStatus.OK) {
            $('#map_canvas').bind('init', function () {
                $('#map_canvas').gmap('addMarker', {
                    'position': lat1 + ',' + lng1
                }).click(function () {
                    $('#map_canvas').gmap('openInfoWindow', {
                        'content': lat1 + ',' + lng1
                    }, this);
                });
            });
        }
    });
}

When i alert the variables in the init function they are undefined, i know this geocoder is async but I am waiting for the status to be ok… Any idea what ive done wrong?

  • 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-04T06:26:42+00:00Added an answer on June 4, 2026 at 6:26 am

    Try it. Geocoder is async but multiple times call callback function.

    geocoder.geocode({"address":user1Location}, function(locResult, status) {
         if (status == google.maps.GeocoderStatus.OK) {
            lat1 = locResult[0].geometry.location.lat();
            lng1 = locResult[0].geometry.location.lng();
         }
    });
    

    Thats working on link in the same code.

    http://jsfiddle.net/2jbTX/2/

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

Sidebar

Related Questions

I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
Im trying to write a function for adding category: function addCategory() { $cname =
I'm trying to modify this: jquery desktop by adding a input field inside one
I'm trying to distinct a column for my autosuggest function. This is the query
Trying this tutorial http://www.wpftutorial.net/ListBoxDataTemplate.html and thought of adding a radio button as follows <ListBox
Im trying to create an additional function for jqGrid to simplify adding JSON data
This is what I'm trying to generate: <div class=marker style=background:transparent url('/myApp/faces/javax.faces.resource/1.png?ln=images/map') no-repeat center top;></div>
I am trying to serialize some Linq objects using this code. private byte[] GetSerializedObj(object
Given this code (C#, .NET 3.5 SP1): var doc = new XmlDocument(); doc.LoadXml(<?xml version=\1.0\?><root>
I am trying to simplify adding stuff to some arrays with a custom function

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.