View Full Version : creating a new editor for the grid

26 Dec 2006, 1:41 PM
I've been using Jack's data editor and date picker code as a starting point to create a new type of a editor - a GeoEditor. Basically the idea is have latitude and longitude in a editor grid cell, someone can edit the values directly in the cell or use a dropdown to access a MapPicker. The MapPicker access the Google maps API and lets the user move around a marker to select an exact location.

I used Google's API to create some control buttons: Help, Re-Center, Cancel, and Save.

I would like Cancel to close the MapPicker and revert back to original latitude and longitude values and Save should just close the MapPicker. Right now these buttons just zoom the map or fdire debugger for Firebug.

To hide the MapPicker, the controls I create using the Google need to access methods from the GeoEditor. Unfortunately, I am not very strong in JavaScript OOP and do not know how to make these methods accessible. Any help would be greatly appreciated.

The example code is located at http://www.dschulman.com/geoeditor/

26 Dec 2006, 3:37 PM
That looks really nice. You should probably devise some way to get a reference to the editor from the child frame. For example (this is very minimal):

YAHOO.ext.MapPickerMgr = function(){
var activeEditor = null;
return {
getActiveEditor : function(){
return activeEditor;

setActiveEditor : function(editor){
activeEditor = editor;

Then when you start editing in the MapPicker, call MapPickerMgr.setActiveEditor(this);

In your map iframe, you can then call:


to get a reference to the active editor. This will also eliminate the the need to update the span elements by id in setpoint() since you can call a function on your editor and have it update them (enabling more than one editor on a page and no id conflicts).

27 Dec 2006, 11:11 AM
Thanks Jack. I played around with this a bit and I think I will now be able to get it to work.

Your library is so robust that I can get it to do cool things even when I understand less than a third of what is going on. Once I complete the functionality and clean up the code some, I will post in the examples section.

Unless anyone else has done one, I also plan on making a comment editor. The pick will open up a textarea for editing longer text entries. I will have an option for some WYSIWYG editor such as tinyMCE and/or FCKeditor.

For both the mapPicker and commentEditor, I think I'll try to use your Resizable container to let end-users make bigger editing areas.

31 Dec 2006, 3:11 AM
Sounds great. Good luck!