Inserting Google Maps into a WYSIWYG editor, then saving and retrieving properly
- by Tatu Ulmanen
Hi,
I'm trying to extend jWysiwyg with an function to add a map from Google Maps. I can get the map all right, but I'm having problems with how to handle the generated map so it can be saved with the page and then retrieved.
To open the process up a bit:
User enters editor which is created using jWysiwyg.
User clicks on a button which asks for an address, then returns the corresponding latitude and longitude.
I use this location information to create a map using Google Maps API (V3), which I then insert into the editable WYSIWYG area.
When I save the page, the whole Google generated HTML gets saved into the database, which will not work properly when opened next time (I get a grey box when I open up the page again).
Now, the problem is that I need to insert the map in such a format that it will work afterwards (perhaps using <script> tags). I also need the map to be visible in the WYSIWYG editor itself, so I cannot just put in a placeholder tag which would later be populated with the correct map data.
So, in short; how would you insert a Google Map into a WYSIWYG editor in a way that it is both visible/previewable from the editor itself and could also be saved in a format that would work properly when opened the next time?