I'm very new to PHP. On a Wordpress site, I want to use custom Google Maps with the Javascript API V3. Some posts will have maps in them, and I want to use PHP variables to determine the unique locations, zoom level, info window text, etc. The Google Maps javascript will be in the footer with all the styles, map type and anything that will be consistent from map to map.
So for posts which have a map, written in the post there will be something like:
<?php
$location = "-34.397, 150.644";
$zoom = "8";
?>
<div id="map"></div>
And in the javascript in the footer theme file will be something like:
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(<?=$location;?>);
var myOptions = {
zoom: <?=$zoom;?>,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
myOptions);
}
</script>
Plus all the other crap that Google requires.
This works fine if I put it in any other php file, but not within Wordpress. What am I doing wrong?