I'm trying to pass the Lat and Long of a city into a gmaps function, in a separate file to where the php variable is created.
gmaps.js :
function getMap(lat) {
alert(lat);
}
main.php :
<div id="map" onload="getMap(<?php echo json_encode($GLOBALS['city']->lat); ?>)"></div>
When I view the page source, I see this :
<div id="map" onload="getMap("51.713")"></div>
But the alert is displaying undefined
.
The .js
file is linked to the .php
and other functions without passed variables work.
I need to be able to pass the variable as displayed in the source.