I'm developing an hybrid app with Cordova, using jQuery Mobile libraries. Since I need to show a map I used and edited the code found here but seems it doesn't recognize the first line of the code.
Geolocation.js
$(document).on("pagecreate", "#map-page", function() { //doesn't work
alert('hello');
function initMap() {
var defaultLatLng = new google.maps.LatLng(44.494887, 11.342616300000032); //Bologna
drawMap(defaultLatLng);
}
function drawMap(latlng) {
var myOptions = {
zoom: 17,
center: latlng,
};
var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: "Parcheggio"
});
}
});
Html container is the same as the demo. The scripts I've included:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/geolocation.js"></script>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD91dMkAWwADchy-WY1-5O7P6nHmjGont0
&callback=initMap"></script>
I've also tried to change API key but nothing changes. Do you know how to solve this problem?