using javscript to replace the src of an embeded google map
Posted: Sun May 31, 2009 10:05 pm
This is what my embeded google maps code looks like:
I would like to make a link so that when you click on it, it updates the src in the iframe above. Thus changing the map.
Here is what I have:
Could some please point me in the correct direction.
Code: Select all
<iframe id="googleMap" width="476" height="345" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&view=map&q=shoreham+verizon+wireless&sll=40.946977,-72.89445&sspn=0.038444,0.090981&gl=us&ie=UTF8&cid=15856891361931225563&ll=40.952029,-72.884502&spn=0.018475,0.036821&z=14&iwloc=A&output=embed"></iframe>Here is what I have:
Code: Select all
<script type="application/javascript">
function switchDirection(newSrc)
{
document.getElementById("googleMap").src=newScr;
}
</script>Code: Select all
<a href="javascript:switchDirection('http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=rocky+point,+ny+to+99+route+25a,+11786&sll=40.941095,-72.920705&sspn=0.023146,0.06609&ie=UTF8&ll=40.941106,-72.92038&spn=0.022692,0.036478&z=14&output=embed');">Rocky Point</a>