我使用locations.push(location)
但它无法保存lat,lng。
这是我的GetLocation(地址):
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<script type="text/javascript">
var locations = [];
function GetLocation(address) {
var geocoder = new google.maps.Geocoder();
var address = address;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat().toFixed(7);
var lng = results[0].geometry.location.lng().toFixed(7);
var location = [lat, lng];
} else {
alert("Request failed.")
}
});
};
</script>