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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:21:35+00:00 2026-06-17T08:21:35+00:00

I am using the google maps jquery google maps . What i intend to

  • 0

I am using the google maps jquery google maps.
What i intend to do is, ask the user to click on a position on the map and then get his
geolocation, data based on the point on the map that he has clicked.

I try the following snippet:

$('#mapCanvas').gmap('click', function(overlay, latlng){
  if (latlng) {
    alert("here");
    marker = new GMarker(latlng, {draggable:true});
    var latlng = marker.getLatLng();
    var lat = latlng.lat();
    var lng = latlng.lng();
    //send these lat and lng to server side save location method through ajax
    console.log(latlng);
  }
  map.addOverlay(marker);
}); 

But this does not work, could someone please tell me what is wrong?
A fiddle can be found here.

Thanks!

  • 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-17T08:21:36+00:00Added an answer on June 17, 2026 at 8:21 am

    To capture events, google.maps.event.addListener is usually used. For example, to capture when a user clicks on the maps, you can do this:

    google.maps.event.addListener(map, 'click', function(event) {
      alert(event.latLng);
    });
    

    The click event in google.maps.Map triggers a MouseEvent, which has a latLng property. This tells you where on the map the user clicked. Similarly, google.maps.Marker behaves the same way, and it tells you where the clicked marker is on the map.

    Combining these two things, we can create an application where markers can be added by clicking on the map, and their locations can be obtained by clicking on the markers:

    google.maps.event.addListener(map, 'click', function(event) {
    
      // add a marker where the mouse clicked
      var marker = new google.maps.Marker({
        position: event.latLng,
        map: map
      });
    
      // when the marker is clicked, alert its location
      google.maps.event.addListener(marker, 'click', function(event) {
        alert('This marker is at: ' + event.latLng);
      });
    
    });
    

    Working example: http://jsfiddle.net/aLEjR/1/


    By the way, if you already have an instance of google.maps.Marker (e.g. if you created that marker yourself), you can get its position by calling the getPosition() method. You can read the API documentation about that method and many others here:

    • https://developers.google.com/maps/documentation/javascript/reference

    You can always learn more about how to use the Google Maps API by reading the Developer’s Guide:

    • https://developers.google.com/maps/documentation/javascript/tutorial
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jquery-ui-map to create a Google Maps instance like this: $('#CHMap').gmap({ mapTypeControl :
I'm writing a Google Maps app that requests data from the server using jQuery's
http://rickgutierrez.bol.ucla.edu/map_mobile6.htm I am working on a mobile map using google maps API and JQuery
using jquery-ui-map here is my code $(document).ready(function() {$('#map_canvas').gmap({ 'center': new google.maps.LatLng(3.162456,21.09375), 'zoom': 2, 'streetViewControl':
I am using the Google Maps API. I get the Google Map by: $map
I am using goMap jQuery plugin for integrating Google Maps api v3. I am
I am using Google Maps V3 API to display my map. Problem: How can
I'm using google maps autocomplete for user to input the place. after that I
I am using Google Maps in order to display current user location. While using
I'm using Google Maps' API and added a few markers in a map. Each

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.