What is the proper way to wrap this php loop around the javascript

Posted by zac on Stack Overflow See other posts from Stack Overflow or by zac
Published on 2010-03-21T19:27:50Z Indexed on 2010/03/21 19:31 UTC
Read the original article Hit count: 198

Filed under:
|
|
|

Hi, I am mashing together the Google Maps 2 script with a Wordpress loop so there is a CMS platform for the map data. I have this working fine :

var point = new GLatLng(48.5139,-123.150531);
var marker = createMarker(point,"Lime Kiln State Park", 
'<?php $post_id = 182;
$my_post = get_post($post_id);
$mapTitle  = $my_post->post_title;
$mapIMG = get_post_meta($post_id, 'mapImage', true);
$snip = get_post_meta($post_id, 'mapExcerpt', true);
echo "<div class=\"span-12\">";
echo "<div class=\"mapTitle\">";
echo $mapTitle;
echo "</div>";
echo "<img class=\"mapImage\" src=\"";
echo bloginfo('url');
echo "/wp-content/files_mf/";
echo $mapIMG;
echo "\" /> ";
echo "<div class=\"mapContent\">";
echo $snip;
echo "</div>";
echo "<div class=\"moreLink\">";
echo "<a href=\"";
echo $permalink = get_permalink( $post_id );
echo "\">Find out more &raquo; </a>";
echo "</div>";
echo "</div>";
?>')
map.addOverlay(marker);

However I am hoping to also be able to include the two variables at the start within the php loop so that both of those can also be generated by custom fields. Can someone please show me that the proper way to write this would be so that all of the data can be pulled in from fields within that post id? So the lat/long and title could also be set from within the post 182 fields.

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about JavaScript