Hi Ian,
I try to keep everything in a component called "glidewx". 
One of its views "components/com_glidewx/views/sites/view.html.php" loads the Google Maps Java Script generating code:
Code: Select all
  function display($tpl = null) {
...
    $document    =& JFactory::getDocument();
...
    $document->addScript('components/com_glidewx/includes/php/glidewx/sitemap-js.php');
...
  }
(I guess the relative URL should be Joomla'fied.)
"sitemap-js.php" has this:
Code: Select all
  $site = new Site();
  $siteList = $site->loadList($siteFilter);
"Site" is the object that represents a hang gliding site. It gets me the latitude and longitude to put a marker on the map. I then iterate through $siteList and putput JavaScript for Google Maps to add a marker: 
Code: Select all
        // Loading the sites:
<?php
        if (is_array($siteList))
        {
            foreach($siteList as $site)
            {
                if ($site->hasGeoLocation())
                {
?>
        var marker<?= $i ?> = new GMarker(new GLatLng(<?= $site->displayGeoLocation() ?>), siteIcon);
        GEvent.addListener(
            marker<?= $i ?>,
            "click",
            function()
            { marker<?= $i ?>.openInfoWindowHtml(
                getInfoWndHtml(<?=
                        $site->id . ',' .
                        $site->type . ',"' .
                        addslashes($site->name) . '","' .
                        addslashes($site->town) . '","' .
                        addslashes($site->state) . '","' .
                        addslashes($site->country) . '","' .
                        addslashes($site->url1) . '","' .
                        addslashes($site->description) . '"' ?>)); }
            );
        batch.push(marker<?= $i ?>);
<?php
                    $i++;
                }
            }
        }
There is more JavaScript, of course. The component's template (components/com_glidewx/views/sites/tmpl/map.php) has a little form to select select country, state to be displayed in the map (simplified here). And then the Google Map:
Code: Select all
<form method="get" action="<?= $_SERVER['PHP_SELF'] ?>">
<fieldset>
State:<input name="state" type="text" id="state" value="<?= $state ?>" size="4" maxlength="2" /> 
<input type="submit" />
</fieldset>
</form>
<div id="map" style="width: 600px; height: 600px"></div>
As I said, it works but is not a pretty solution. I.e. the variable "$state" used in the form of the template is filled in the PHP file that is included to the page through a JavaScript  tag:
Code: Select all
<script type="text/javascript" src="components/com_glidewx/includes/php/glidewx/sitemap-js.php"></script>
I am thinking about hacking JDocument and adding a method that allows me to include a PHP file at the top of the Joomla template. You said I could do that through a module, but I'd like to keep all the weather application stuff within the component. 
Did that make things a little more clear? Sorry for the long post, thanks for listing. 
Holger