Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  6] [ 6]  / answers: 1 / hits: 18055  / 14 Years ago, tue, november 30, 2010, 12:00:00

As you can see, there is a line in there that does an alert. It's undefined. Whereas if I just alert results[0].geometry.location, it alerts (41.321, 41.556).



I just want to alert it and set it (as an int) to one of my id_lat and id_longs...



$(#geocodesubmit).click(function(){
$(#id_lat).val();
$(#id_long).val();
var address = $(#addressinput).val();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
$(#badlocation_holder).hide();
$(#map_canvas).show();
$(#map_canvas_holder).show().css(background-color, #E6E6FA).animate({background-color:#f5f5f5}, 800);
;
var map = new google.maps.Map(document.getElementById(map_canvas), myOptions);
map.setCenter(results[0].geometry.location);

alert(results[0].geometry.location[1]); //this is undefined.

$(#id_lat).val(results[0].geometry.location[0]);
$(#id_long).val(results[0].geometry.location[1]);


var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
draggable:true
});
} else {
$(#map_canvas_holder).hide();
$(#badlocation_holder).show().css(background-color,#F08080).animate(
{background-color:#f5f5f5},800);
}
});
return false;
});

More From » html

 Answers
7

Use results[0].geometry.location.lat() to get the latitude and results[0].geometry.location.lng() for the longitude.


[#94795] Saturday, November 27, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
teagan

Total Points: 98
Total Questions: 106
Total Answers: 101

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
teagan questions
Fri, Mar 5, 21, 00:00, 3 Years ago
Mon, Feb 15, 21, 00:00, 3 Years ago
;