[ka-Map-users] iframe passing extents back to containing page

percy percyd at pdx.edu
Sun Aug 13 10:37:25 EDT 2006


Hi Paul, below is the code we ended up using, in case it helps anyone 
else...
And here's the page it's in for testing:
http://geospatial.research.pdx.edu/~bjpd/usgs/ngm_quicksearch9.html

Thanks again,
Percy

-------------------iframe code to dump extents into hidden fields for 
database search----------------
<iframe id = "geosrchmap" name= "geosrchmap" src = 
"http://geospatial.research.pdx.edu/~bjpd/kamap-cvs/htdocs/iframe.html" 
width = "100%" height = "400">
</iframe>
<input name = "showextents" value ="Use This Extent" type = "button" 
onclick = "storeExtents()">
<script type = "text/javascript" language = "javascript">
function storeExtents()
{
var myextents = 
document.getElementById('geosrchmap').contentWindow.myKaMap.getGeoExtents()
//alert(myextents)
document.getElementById('kaminx').value = myextents[0]
document.getElementById('kaminy').value = myextents[1]
document.getElementById('kamaxx').value = myextents[2]
document.getElementById('kamaxy').value = myextents[3]
}

</script>
<input id="kaminx" name="kaminx" type = "hidden" value="" >
<input id="kaminy" name="kaminy" type = "hidden" value="" >
<input id="kamaxx" name="kamaxx" type = "hidden" value="" >
<input id="kamaxy" name="kamaxy" type = "hidden" value="" >
---------------------------------------------------------------------------------------------------------

Paul Spencer wrote:
> Percy,
>
> I'll try to catch you on IRC (pagameba) but in case I don't ...
>
> If your iframe is loaded from the same site as your main page, then 
> you are allowed to script between them.  Whatever triggers your query, 
> you can do one of the following:
>
> 1) from the main page (in response to clicking a button or something), 
> you can call the kaMap object in the frame ...
>
> document.getElementById('frameid').contentWindow.myKaMap.getExtents();
>
> 2) from the iframe (in response to an event for instance), you can 
> call a function in the parent window ...
>
> window.parent.someFunction();
>
> Cheers
>
> Paul
>
> On 31-Jul-06, at 1:19 PM, percy wrote:
>
>> I would like to embed a kamap iframe within a database search page and
>> have it pass back the extent of what the user has zoomed to so that I
>> can use this in a query to my database.
>>
>> the goofy part is that the embedding page is a Perl CGI, so I think 
>> I'm stuck using Perl mapscript to access the iframe's properties.
>>
>> any hints on the best way to do this? I'm on the IRC right now...
>>
>> thanks,
>> percy
>>
>> PS I searched the mailing list archives already...
>>
>> _______________________________________________
>> ka-Map-users mailing list
>> ka-Map-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/ka-map-users
>
> +-----------------------------------------------------------------+
> |Paul Spencer                           pspencer at dmsolutions.ca   |
> +-----------------------------------------------------------------+
> |Applications & Software Development                              |
> |DM Solutions Group Inc                 http://www.dmsolutions.ca/|
> +-----------------------------------------------------------------+
>
>
>
>
>



More information about the ka-Map-users mailing list