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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:20:09+00:00 2026-05-23T04:20:09+00:00

Errors: latlng is undefined(var lng = latlng.lng(); ) Although it gets a value and

  • 0

Errors:
latlng is undefined(var lng = latlng.lng(); ) Although it gets a value and put in textboxes
no response from ajax. I want response as text, not xml. What I am missing?

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
//map.addControl(new GMap2TypeControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);

GEvent.addListener(map, "click", function(overlay, latlng) {
var inputForm = document.createElement("form");
inputForm.setAttribute("action","");
inputForm.onsubmit = function() {storeMarker(); return false;};
//retrieve the longitude and lattitude of the click point
var lng = latlng.lng();
var lat = latlng.lat();
inputForm.innerHTML = '<fieldset style="width:150px;">'
+ '<legend><b>Add Property<b></legend>'
+ '<label for="name"><B>Name</b></label>'
+ '<input type="text" id="name" style="width:100%;"/>'
+ '<label for="address"><b>Address</b></label>'
+ '<input type="text" id="address" style="width:100%;"/>'
+ '<label for="address"><b>Type</b></label>'
+'<select id="type"><option>Homes</option><option>Plots</option><option>Commercials</option></select>'
+ '<label for="address"><b>Prperty Type</b></label>'
+'<select id="property_type"><option>Sale</option><option>Rent</option><option>Wanted</option></select>'
+ '<label for="address"><b>Descreption</b></label>'
+ '<textarea id="description" cols="15" rows="4" name="description"></textarea>'
+ '<input type="text" id="longitude" value="' + lng + '"/>'
+ '<input type="text" id="latitude" value="' + lat + '"/>'
+ '<input type="submit" value="ADD"/>'
+ '</fieldset>';

map.openInfoWindow (latlng,inputForm);
});
}
}

Here is the store marker function:

function storeMarker(){
//alert("xainee");
var lng = document.getElementById("longitude").value; //getting the longitude
var lat = document.getElementById("latitude").value;//getting the latitude

alert(lng +"and"+lat);
//geeting the user data in form
var getVars =  "storeMarker.php?name=" + document.getElementById("name").value
+ "&address=" + document.getElementById("address").value
+ "&description=" + document.getElementById("description").value
+ "&property_type=" + document.getElementById("property_type").value
+ "&type=" + document.getElementById("type").value
+ "&lng=" + lng
+ "&lat=" + lat ;

//alert(getVars);
//////////////////////////////////////////
var Request = false;
 if (window.XMLHttpRequest) {
  Request = new XMLHttpRequest();
 } else if (window.ActiveXObject) {
  Request = new ActiveXObject("Microsoft.XMLHTTP");
 }

 if (Request) {
     alert("workinh");
     Request.open("GET","storeMarker.php"+getVars,true);

     Request.onreadystatechange=function()
  {
  if (Request.readyState==4 && Request.status==200)
    {
    document.write(responseText);
    }
  }
   Request.send(null);
}

}

And here is the storeMarker.php page:

<?php
include_once('clsGeneral.php');
echo $name=$_GET['name'];
echo $address=$_GET['address'];
echo $type=$_GET['type'];
echo $property_type=$_GET['property_type'];
echo $descreption=$_GET['description'];
echo $lat=(float)$_GET['lat'];
echo $lan=(float)$_GET['lng'];

$my_query="INSERT INTO map_marker SET name='$name',
    address='$address',type='$type',property_address='$property_type',
    descreption='$descreption',lat='$lat',lan='$lat'";
db_execute($my_query);
?>

My problem is that when Geventlistner is fired through click so popup is rendered showing all elements with latitude and longitude values in textboxes but when I click in any textbox it shows an error “latlan is not defined”. Second it’s not sending the request and for instance it send than no response in here I want response in string not in XML.

  • 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-23T04:20:09+00:00Added an answer on May 23, 2026 at 4:20 am

    According to the fine Google Maps manual:

    Many events in the Maps API event system pass arguments when the event is triggered. For example, the GMap2 “click” event passes an overlay and overlaylatlng if the map click occurs on an overlay; otherwise, it passes a latlng of the map coordinate. You can access these arguments by passing the specified symbols directly to the functions within the event listeners.

    In the example below, we first test to ensure the click was on a map tile by checking if the latlng argument is defined; if so, we open an info window above the clicked coordinate and display the coordinate converted to pixel space along with the zoom level.

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

Sidebar

Related Questions

I want my errors to float above, left-justified, the input field that doesn't validate.
navigator.geolocation.getCurrentPosition( function(pos) { var fullpos = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude); computePartners(fullpos); } ); is what
My script containing that error is this: $stmt = $this->db->prepare('SELECT libelle,activite,adresse,tel,lat,lng FROM etablissements where
I'm using simpliest example from the official documentation: function initialize() { var mapCent =
var circle = new google.maps.Circle({ center: latLng, radius: radius, strokeColor: #FF0000, strokeOpacity: 0.5, strokeWeight:
I have a google map which I am getting json data from. I want
Errors that occur deep down in a data access layer or even higher up,
I'm seeing strange errors when my C++ code has min() or max() calls. I'm
I keep getting compiler errors when I try to access flashVars in an AS3
I am getting some errors thrown in my code when I open a Windows

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.