I have a google map script like this which is the standard google map script provided in JQuery forum some where
<script type="text/javascript">
/*
* Google Maps documentation: http://code.google.com/apis/maps/documentation/javascript/basics.html
* Geolocation documentation: http://dev.w3.org/geo/api/spec-source.html
*/
$( document ).on( "pageinit", "#map-page", function() {
<?php $coordenadas=explode(',',$fila['Googlemap']);?>
var defaultLatLng = new google.maps.LatLng(<?php echo $coordenadas[0];?>,<?php echo $coordenadas[1];?> );
drawMap(defaultLatLng); // Default to Hollywood, CA when no geolocation support
function drawMap(latlng) {
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
// Add an overlay to the map of current lat/lng
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: "Greetings!"
});
}
});
</script>
If you see in the code I am trying to pass longitude and latitude values extracted from a php variable to the function draw_map(); . But I am not able to do that. Can someone please help me with this ?
Edit-1
Now the map is working with the solution provided by @sukhwinder but another problem is that the map is not centered to the screen . When I open in the mobile browser the marking is shown in the top left corner and the map is not visible totally .