Hi,
I want to get lat and lng values separate: please see code below
This is my code. I want these values back in function
codeLatLng(latlng, map) on line one.
var geocoder;
var map;
var infowindow = new google.maps.InfoWindow();
var marker;
function create_current_location_map(lat, lng) {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom : 11,
center : latlng,
mapTypeId : google.maps.MapTypeId.HYBRID,
draggableCursor : 'crosshair'
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function(me) {
codeLatLng(me.latLng, me.map);
});
}
function codeLatLng(latlng, map) {
//I need lat and lng values here separate so that I can send them to
server to save in database Please help me
if (geocoder) {
geocoder.geocode( {
'latLng' : latlng
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
marker = new google.maps.Marker( {
position : latlng,
map : map
});
infowindow.setContent(results[1].formatted_address);
infowindow.open(map, marker);
$("#location").text(results[1].formatted_address);
$("#address").val(results[1].formatted_address);
$("#location").removeClass('error');
} else {
$("#location").text('Geocoder failed
due to: ' + status);
$("#location").addClass('error');
}
}
});
}
}
Thanks for any response.
--
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en.