Is it possible to echo PHP in a javascript? i want to echo google coordinates in a javascript to center the map. The coordinates comming from the database (PhpMyAdmin)
The results from the echo are 50.9272511, 4.425786799999969
Check the following code out:
<script type='text/javascript'>
function init_map() {
var myOptions = {
zoom: 10
, center: new google.maps.LatLng(<?php echo $box['coordinates'];?>)
, mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('gmap_canvas'), myOptions);
//1
marker = new google.maps.Marker({
map: map,
position: new google.maps.LatLng()
});
infowindow = new google.maps.InfoWindow({
content: '<strong>TEST</strong><br>Den helder, nederland<br>'
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
infowindow.open(map, marker);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>