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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:26:10+00:00 2026-05-31T09:26:10+00:00

I’m setting up a form within an info info window for crowd-sourcing location data.

  • 0

I’m setting up a form within an info info window for crowd-sourcing location data. I’ve got everything up and running, but I’m trying to copy the lat and lng values into the form elements when the info window pops open.

I’ve been successful with other event listener on the map div, but when I use the domreadyevent handler for the info window I get an error:

“Uncaught TypeError: Cannot read property ‘__e3_’ of undefined.”

The issue seems to be within the domready event listener.

// Global Variables
var map, markerWindow, newMarker;

function updateMarkerPosition(latLng) {
    alert(latLng);
    var lat = latLng.lat().toString();
    var lng = latLng.lng().toString();
    google.maps.event.addListener(markerWindow, "domready", function() {
        alert(latLng); // debug alert
        document.getElementById('lat').value = lat.slice(0,6);
        document.getElementById('lng').value = lng.slice(0,7);
    });
}
function placeMarker() {
// Setup html form markup for marker pop-up infowindow
    var html = '<div id="htmlform">' +
        '<form action="process.php" method="post" ' +
        'id="mapForm"> <fieldset> <label for="contact">' +
        'Email:</label><input type="text" name="contact"/>' +
        '<br/> <label for="date">Date:</label><input ' +
        'type="text" name="date"/><br/> <label for="desc">' +
        'Description of Sighting:</label><input type="text" ' +
        'name="desc"/><br/> <label for="lat">Latitude:</label>' +
        '<input type="text" name="lat" id="lat" class="location"/><br/>' +
        '<label for="lng">Longitude:</label><input type="text"' +
        'name="lng" id="lng" class="location"/><br/><input type="submit"' +
        'value="Post Sighting!" onclick="saveData()"/> </fieldset></form>' +
        '</div>';
    var newMarker = new google.maps.Marker( {
        draggable: true,
        map: map,
        animation: google.maps.Animation.DROP,
        title: "I'm draggable!",
    });
    var markerWindow = new google.maps.InfoWindow({
        content: html,
    }); 
    google.maps.event.addListener(map, "click", function(e) {
        newMarker.setPosition(e.latLng);
        markerWindow.open(map, newMarker);
        map.setCenter(e.latLng);
        updateMarkerPosition(newMarker.getPosition());
    });             
    google.maps.event.addListener(newMarker, 'dragstart', function() {
        markerWindow.close();
    });
    google.maps.event.addListener(newMarker, 'dragend', function(e) {
        newMarker.setPosition(e.latLng);
        markerWindow.open(map, newMarker);
        updateMarkerPosition(newMarker.getPosition());
    });
}
// Run when DOM window loads
function initialize() {
    map = new google.maps.Map(document.getElementById('map_canvas'),{
        zoom: 8,
        center: new google.maps.LatLng(38.487, -75.641),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    placeMarker();
}
google.maps.event.addDomListener(window, 'load', initialize);
  • 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-31T09:26:11+00:00Added an answer on May 31, 2026 at 9:26 am

    Alright, I did it without the timeout!

    // Global Variables
    var map, markerWindow, newMarker;
    
    function placeMarker() {
    // Setup html form markup for marker pop-up infowindow
        var html = '<div id="htmlform">' +
            '<form action="process.php" method="post" ' +
            'id="mapForm"> <fieldset> <label for="contact">' +
            'Email:</label><input type="text" name="contact"/>' +
            '<br/> <label for="date">Date:</label><input ' +
            'type="text" name="date"/><br/> <label for="desc">' +
            'Description of Sighting:</label><input type="text" ' +
            'name="desc"/><br/> <label for="lat">Latitude:</label>' +
            '<input type="text" name="lat" id="lat" class="location"/><br/>' +
            '<label for="lng">Longitude:</label><input type="text"' +
            'name="lng" id="lng" class="location"/><br/><input type="submit"' +
            'value="Post Sighting!" onclick="saveData()"/> </fieldset></form>' +
            '</div>';
        var newMarker = new google.maps.Marker( {
            draggable: true,
            map: map,
            animation: google.maps.Animation.DROP,
            title: "I'm draggable!",
        });
        var markerWindow = new google.maps.InfoWindow({
            content: html,
        }); 
        google.maps.event.addListener(map, "click", function(e) {
            newMarker.setPosition(e.latLng);
            markerWindow.open(map, newMarker);
            map.setCenter(e.latLng);
        });             
        google.maps.event.addListener(newMarker, 'dragstart', function() {
            markerWindow.close();
        });
        google.maps.event.addListener(newMarker, 'dragend', function(e) {
            newMarker.setPosition(e.latLng);
            markerWindow.open(map, newMarker);
        });
        google.maps.event.addListener(markerWindow, 'domready', function() {
          latLng = newMarker.getPosition();
          var lat = latLng.lat().toString();
          var lng = latLng.lng().toString();
          document.getElementById('lat').value = lat.slice(0,6);
          document.getElementById('lng').value = lng.slice(0,7);
        });
    }
    // Run when DOM window loads
    function initialize() {
        map = new google.maps.Map(document.getElementById('map_canvas'),{
            zoom: 8,
            center: new google.maps.LatLng(38.487, -75.641),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });
        placeMarker();
    }
    
    google.maps.event.addDomListener(window, 'load', initialize);
    

    I have a different idea without the “domready” listener. I’ve seen another question where you need to wait a timeout after closing the Infowindow to prevent a click propagation. In your case, waiting some time after the InfoWindow is created allows the latLng to be placed in your mini-form. I wonder if the domready really fires after the form is placed or not.

    What I’m suggesting is updating this function:

    function updateMarkerPosition(latLng) {
        var lat = latLng.lat().toString();
        var lng = latLng.lng().toString();
    
        setTimeout(function() { 
          document.getElementById('lat').value = lat.slice(0,6);
          document.getElementById('lng').value = lng.slice(0,7);
        }, 200);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
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 have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.