So, when I do this:
<!-- javascript file -->
function geocodeFromAdress(address) {
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latLng = results[0].geometry.location;
console.log(latLng.lat() + ", " + latLng.lng());
return latLng.lat() + ", " + latLng.lng();
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
<!-- HTML view -->
<script type="text/javascript">
$(function(){
myOptions = {
center: new google.maps.LatLng(geocodeFromAdress('Los Angeles')),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Gmaps.map = new google.maps.Map($('.map')[0], myOptions);
addFacilities(Gmaps.map);
});
</script>
the map is not rendered, but if I do:
<script type="text/javascript">
$(function(){
myOptions = {
center: new google.maps.LatLng(34.0522342, -118.2436849),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Gmaps.map = new google.maps.Map($('.map')[0], myOptions);
addFacilities(Gmaps.map);
});
</script>
then the maps is properly rendered. Why it doesn't accept the coordinations from the JS function?
The output of the JS function: 34.0522342, -118.2436849
Thank you in advance.