tags:

views:

25

answers:

1

I currently have a map mashup that has locations that I'm populating from my own database. A few users would like to also show that map on their site(s). I'd like to give them the ability to do that, but would like to retain the actual functionality of the map on my own site: like add "stuff" to places on the map through my a web form on my site. I could open the entire API to allow them to create their own form along with the data points, but most of the people wanting to put up the map aren't developers, they are just enthusiasts that have put together a personal page that they want to spice up.

I was thinking I could just provide a JavaScript of some kind that they could then take to place on their site, or maybe an IFRAME of some type, or...any ideas? Anyone implemented this? TIA.

+1  A: 

I haven't done anything like this myself, but I think your idea to utilise an iframe is on the right track. In fact, this is how Google Maps generates its embed code.

Your app will need to generate a URL with all relevant Google Map parameters such as bounds, zoom level as well as your application-specific params. Any event that triggers the map to re-draw (drag, zoom, etc.) will generate a new URL.

If you try the embed link in Google Maps as an example, it generates a URL that looks something like this:

http://maps.google.com/maps?f=q&source=s_q&sll=45.434035,12.339057&sspn=0.003294,0.004812&ie=UTF8&ll=45.432724,12.338966&spn=0.006588,0.009624&t=h&z=17

This URL can then be wrapped up in an iframe which your end users can place on their web pages.

Re: resizing

Yes, it's possible to dynamically resize it if width/height is part of your application params that generates the embed code. Again using Google Maps as an example:

<iframe
   src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;sll=45.434035,12.339057&amp;sspn=0.003294,0.004812&amp;ie=UTF8&amp;ll=45.432724,12.338966&amp;spn=0.006588,0.009624&amp;t=h&amp;z=17&amp;output=embed"
   width="(width-param)" height="(height-param)"></iframe>

If you mean resized by user, after it's been displayed, I'm not sure.. most likely, yes.

armandino
Is there easy ways to resize the iframe so a user could fit it to their site? I thought it was a fixed width/height but could be wrong. I'll look into this, thanks for the suggestion.
rball