My Script is
<script type="text/javascript">
var lat = <%= @town.latitude %>,
lon = <%= @town.longitude %>,
map;
function initialize() {
var myOptions = {
center: new google.maps.LatLng(lat, lon)
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
<script type="text/javascript" src="//maps.google.com/maps?file=api& v=2.x&key="My api key"&libraries=places"></script>
I can fetch latitude and longitude but my map is not loading.Could anyone help me with this?
Aucun commentaire:
Enregistrer un commentaire