I'm mashing together the Google Maps 2 script having a Wordpress loop so there's a Content management systems platform for that map data. I've 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>";

However am wishing also to have the ability to range from the two variables in the beginning inside the php loop to ensure that each of individuals may also be produced by custom fields. Can someone please show me that the best way to write this is to ensure that all the data could be drawn in from fields within that publish id? Therefore the lat/lengthy and title may be set from inside the publish 182 fields.

I believe I recieve what you are asking. I believe the greatest factor that will assist you to is searching at the coding conventions. Readability is essential. For instance, do not mix php with output an excessive amount of. Perform the php first, after which further lower the page just echo your prepared variables in which you need them. It can make things a great deal simpler to see. Also, single quotes are the friend.

In my opinion this fixes your condition:

$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);
$permalink = get_permalink( $post_id );

// Is this what you mean??
$lat = $my_post->post_lat;
$long = $my_post->post_long;

$pass_to_function = '
    <div class="span-12">
        <div class="mapTitle">'.$mapTitle.'</div>
        <img class="mapImage" 
            src="'.bloginfo('url').'/wp-content/files_mf/'.$mapIMG.'" />
        <div class="mapContent">'.$snip.'</div>
        <div class="moreLink">
            <a href="'.$permalink.'">Find out more &raquo; </a>


var point = new GLatLng(<?php echo $lat.', '.$long; ?>);
var marker = createMarker(point,"<?php echo $mapTitle; ?>", '<?php echo $pass_to_function; ?>')

Eliminate all echos making it by doing this:

$snip = get_post_meta($post_id, 'mapExcerpt', true); 
<div class="span-12"> 
<div class="mapTitle">

I'd do that like a comment, there is however no coding formating there, so...

"... I will be tugging from about 20 different publish IDs..."

How are these publish IDs retrieved? From the database? What information is being drawn? I am speculating the latitude/longitude, the marker title, and also the marker's ID, right? If that is the situation, then something similar to this could work:

$sql = "SELECT id, lat, long, name FROM table..."; // whatever it would be
$res = mysql_query($sql);

while($row = mysql_fetchrow_array($res)) {
    $title = get_title($row['id']);
    $img = get_Post_Meta($row['id']);
    // and populate more variables for whatever data you need

    // start a heredoc
    echo <<<EOF
var point = new GLatLng({$row['lat']},{$row['long']});
var marker = createMarker(point,"{$row['name']}", '
    <div class="this">
       <div class="that">
           {$title}    <img src="{$img}" />

    } // end of while loop

Just be sure you sanitize any text you are placing as Javascript code. If (say) the marker's title consists of exactly the same kind of quotes you are placing it within, it'll result in a javascript syntax error, so make sure to escape the right quotes for whatever you are placing the variable into.