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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:29:30+00:00 2026-05-24T10:29:30+00:00

I’m trying to write a Drupal module that will add UTM coordinate fields to

  • 0

I’m trying to write a Drupal module that will add UTM coordinate fields to a location form, such that they’ll interact properly with the GMap map as well as the Latitude and Longitude fields – i.e. when the map is clicked, the UTM coordinates get calculated and populated along with the Lat/Long ones, and if the Lat/Long coordinates are changed by typing in the fields, the UTM coordinates change also, as well as the map, and vice versa.

I have the translation and everything else working except for clicking the map. I’m trying to add a Listener to the map so that when it’s clicked, a change event will get triggered on the lat/long fields, which would in turn trigger the updating of the UTM fields. But, I can’t seem to get the Listener to work. here’s what I have so far (this is a snippet of my js file for my module, location_utm.js):

$(document).ready(function() {
    var themap = document.getElementById("gmap-auto1map-gmap0");

    Drupal.gmap.addHandler('gmap', function (themap) {
      var obj = this;

      var clickListener = GEvent.addListener(obj, "click", function() {           

         /* when the map gets clicked, trigger change event on the lat/long 
          fields so that the utm fields get updated too.   */
         $('#gmap-auto1map-locpick_longitude0').change();
         $('#gmap-auto1map-locpick_latitude0').change();



      });
   });
});

I’ve tried a lot of different slight variations of this code but can’t seem to get it right. I appreciate any advice.

  • 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-24T10:29:31+00:00Added an answer on May 24, 2026 at 10:29 am

    Please see the code comments:

    if (GBrowserIsCompatible()) 
    {
      Drupal.gmap.addHandler('gmap', function(elem, context) {
        var gmap = this;
    
        // Note: GMap module does not support solely
        // "locpickchange_dragend" and "locpickchange_click" events
        // by default. It combines map clicks, marker drag and
        // dragend events in an custom event called "locpickchange". 
        // Binding on those said solely triggers relies on a GMap
        // locpick widget patch which is included.
        //
        gmap.bind('locpickchange', function(context) {
    
        // Note: The coordinations stored in gmap.vars.latitude and
        // gmap.vars.longitude are for the previous location of the
        // locpicker marker, we need to use gmap.locpick_coord which
        // is pretty live!
        //
        if (gmap.locpick_coord) {
    
          // TODO: Implement the logic.
          // Current latitude: gmap.locpick_coord.lat()
          // Curren longitude: gmap.locpick_coord.lng()
    
        }
      });
    }
    

    In case that you want to use locpickchange_click & locpickchange_dragend, here is the dirty GMap module’s patch:

    From 2fb5a1ca71e1470e5413f10fb83ce959cd1d8634 Mon Sep 17 00:00:00 2001
    From: Sepehr Lajevardi <me@sepehr.ws>
    Date: Fri, 8 Jul 2011 14:38:27 +0430
    Subject: [PATCH] Extends the locpick widget event system by adding
     lockpickchange_click and locpickchange_dragend custom
     events.
    
    ---
     js/locpick.js |   18 ++++++++++++++++++
     1 files changed, 18 insertions(+), 0 deletions(-)
    
    diff --git a/js/locpick.js b/js/locpick.js
    index d5aae9c..7c207f9 100644
    --- a/js/locpick.js
    +++ b/js/locpick.js
    @@ -16,6 +16,18 @@ Drupal.gmap.addHandler('gmap', function (elem) {
         }
       });
    
    +  // Bind triggering of a map click on our custom events.
    +  obj.bind("locpickchange_dragend", function () {
    +    if (obj.locpick_coord) {
    +      GEvent.trigger(obj.map, "click", null, obj.locpick_coord);
    +    }
    +  });
    +  obj.bind("locpickchange_click", function () {
    +    if (obj.locpick_coord) {
    +      GEvent.trigger(obj.map, "click", null, obj.locpick_coord);
    +    }
    +  });
    +
       obj.bind("locpickremove", function () {
         obj.map.removeOverlay(obj.locpick_point);
         obj.locpick_coord = null;
    @@ -40,10 +52,16 @@ Drupal.gmap.addHandler('gmap', function (elem) {
               GEvent.addListener(obj.locpick_point, 'dragend', function () {
                 obj.locpick_coord = obj.locpick_point.getLatLng();
                 obj.change('locpickchange', binding);
    +            // Also trigger a locpickchange_dragend event
    +            // so we can bind on just marker dragends.
    +            obj.change('locpickchange_dragend', binding);
               });
               obj.locpick_coord = point;
               obj.map.panTo(point);
               obj.change('locpickchange', binding);
    +          // Also trigger a locpickchange_click event
    +          // so we can bind on just map clicks.
    +          obj.change('locpickchange_click', binding);
             }
             else {
               // Unsetting the location
    -- 
    1.7.6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to loop through a bunch of documents I have to put
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.