question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

map marker events not working

See original GitHub issue

$(document).on("google_point_map_widget:marker_create", function (e, lat, lng, locationInputElem, mapWrapID) { console.log(locationInputElem); // django widget textarea widget (hidden) console.log(lat, lng); // created marker coordinates console.log(mapWrapID); // map widget wrapper element ID }); I tried the above code following the docs , I am unable to trigger the event. Please do help?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
erdemcommented, Apr 3, 2017

Hi @nakul-sayone

I also tested the triggers on django admin and it is worked too. Did you notice django admin jQuery namespace? Django admin using a different namespace for built-in jQuery. (django.jQuery)

You must read this documentation first. https://docs.djangoproject.com/en/1.10/ref/contrib/admin/javascript/

Here is my django admin implementation:

{% extends 'admin/change_form.html' %}
{% block admin_change_form_document_ready %}
    {{ block.super }}
    <script type="text/javascript">
        (function($) {
            $(document).on("google_point_map_widget:marker_create", function (e, lat, lng, locationInputElem, mapWrapID) {
                console.log(locationInputElem); // django widget textarea widget (hidden)
                console.log(lat, lng); // created marker coordinates
                console.log(mapWrapID); // map widget wrapper element ID
            });

            $(document).on("google_point_map_widget:marker_change", function (e, lat, lng, locationInputElem, mapWrapID) {
                console.log(locationInputElem); // django widget textarea widget (hidden)
                console.log(lat, lng);  // changed marker coordinates
                console.log(mapWrapID); // map widget wrapper element ID
            });

            $(document).on("google_point_map_widget:marker_delete", function (e, lat, lng, locationInputElem, mapWrapID) {
                console.log(locationInputElem); // django widget textarea widget (hidden)
                console.log(lat, lng);  // deleted marker coordinates
                console.log(mapWrapID); // map widget wrapper element ID
            })
        })(django.jQuery);
    </script>
{% endblock %}

if your Django version under 1.9, you can also override extrahead block on admin templates.

Thanks.

0reactions
nakul-sayonecommented, Apr 3, 2017

Hi @erdem it is working in the front end. I need the events in the backend admin page. I tried with a lot of combinations but it doesn’t works. could you please walk me through this? its kind of urgent

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Maps API marker click event not firing - Stack Overflow
Problem with the following code is that the click event is not fired. The markers appear on the map as expected, but when...
Read more >
Events | Maps JavaScript API - Google Developers
For the full list, see the Marker class. These events may look like standard DOM events, but they are actually part of the...
Read more >
Click event doesn't work with Google Maps
First thing I notice is creating the marker outside the initMap function does'n't work. Second thing is wrapping this marker variable into a ......
Read more >
how to pass data to a marker click function - Google Groups
(also) clicking on a Marker. So, tradionally you cannot assign a single event listener to the Map to handle ALL Marker clicks. I've...
Read more >
Google Maps Events - W3Schools
Google Maps Events · Click The Marker to Zoom · Pan Back to Marker · Open an InfoWindow When Clicking on The Marker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found