[Chameleon] Creating my own Widget

Robin Robin querada499 at hotmail.com
Fri Sep 10 14:38:23 EDT 2004


Hi everyone,

Just sending out the good news.  My widget now works (well it's working as 
another query widget at the moment)!  For future reference, here is what I 
did:
(I am just creating a widget that is slightly modified from an existing one)

1)  In the Widgets Folder, copy the entire folder for the widget you are 
planning to modify (mine was query)
2)  Place a copy of the above folder in the Widgets folder and rename it to 
your new widget name
3)  Open your new folder and rename all the files.  For example, I was using 
the query widget to make a hotlink widget, so I changed Query.Widget.php to 
Hotlink.Widget.php.  Do the same for all the files in your new folder
4)  Open the YourName.Widget.php and do a search and replace.  I did a 
search for Query and replaced with Hotlink. Save
5)  You may need to do similar search and replace moves on the other files.  
I think this would depend on the widget you are creating.  I didn't need to 
change any other files (not yet anyway:)
6)  In the Widget folder, find the MapDHTMLWidget folder and inside that, 
open the MapDHTMLWidget.js file (you may want to make a copy of this before 
you start messing with it, just to be safe, just make sure the one you are 
changing is called MapDHTMLWidget.js so you don't have to change any 
references to it).  Do a search for the original widget name and add similar 
lines of code under with your widget name inserted.  For example, I found:
gMapDHTMLForm.NAV_CMD.value == "QUERY" ||

so under it I inserted:
gMapDHTMLForm.NAV_CMD.value == "HOTLINK" ||

Make sure that everything still makes sense after you do this.  I forgot to 
put the || after the query line one time and another I had to remove the 
ending brackets from the query line and move them to the hotlink line.  It's 
not hard, you just have to pay attention to what the code is trying to do 
and make sure it still does the same thing when you're done.

Now you can add your new widget to your map.  Hope this helps people out.

Sorry to be so longwinded, I'm hoping this helps out someone in my situation 
later.  Thanks for all the help.

Robin


>From: "Ken Sanderson" <ken at rockies.ca>
>To: <chameleon at lists.maptools.org>
>Subject: RE: [Chameleon] Creating my own Widget
>Date: Fri, 10 Sep 2004 11:29:29 -0600
>
>When I created my Nav tools widget I needed to add some changes to the
>MapDHTMLWidget.js file in the MapDHTMLWidget folder in the widgets
>directory.
>
>Open that file and look in the functions:
>
>MapWchkMouseUp, MapWmapTool, and MapWgetMouse.
>
>There are parts in each of those that look something like this:
>
>     if((window.gMapDHTMLForm != null) &&
>        (gMapDHTMLForm.NAV_CMD != null) &&
>        (gMapDHTMLForm.NAV_CMD.value == "PAN_MAP" ||
>         gMapDHTMLForm.NAV_CMD.value == "RULER" ||
>         gMapDHTMLForm.NAV_CMD.value == "QUERY" ||
>         gMapDHTMLForm.NAV_CMD.value == "GetPoint"))
>         return true;
>
>Its slightly different in each one, but you will be able to recognize
>it. GetPoint is my widget, you can see how I added it there. Basically
>since QUERY is in every one I suspect that a query type widget also
>needs to be there, so put your own widget name in those lists.
>
>Ken
>Miistakis
>
>-----Original Message-----
>From: chameleon-bounces at lists.maptools.org
>[mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Robin Robin
>Sent: September 10, 2004 7:51 AM
>To: chameleon at lists.maptools.org
>Subject: [Chameleon] Creating my own Widget
>
>
>Hello all,
>
>I am trying to create my own widget and I am running into some problems.
>I
>am trying to create a hotlink widget which will work similar to identify
>but
>will open a webpage when the location on the map is clicked.  I plan to
>do
>this by copying and modifying the query widget.
>
>I started by simply copying the query widget and renaming it.  I wanted
>to
>check that it still worked once the name has been changed.  It doesn't!
>So
>far, I changed the folder name to Hotlink, I have changed
>QueryResults.phtml
>to HotlinkResults.phtml and Query.widget.php to Hotlink.widget.php.  I
>have
>also changed in Hotlink.widget.php the class and constructor names from
>Query to Hotlink (as per instructions in an old thread I found in the
>chameleon archives).
>
>When I click on my hotlink button the map redraws and nothing happens.
>If I
>click the same point with my identify/query button I get a popup window
>with
>the query results.  Since I haven't changed any of the actual
>functionality
>yet, both buttons should produce the same results.
>
>Are there other places where I have to change/add to files so that my
>new
>widget will be recognized?  In an older message someone mentioned
>changing
>the MapDHTMLWidget.widget.php but I couldn't tell where it should be
>changed
>(I did a text search for query).
>
>Any help would be appreciated.
>
>Thanks
>
>_________________________________________________________________
>The new MSN 8: advanced junk mail protection and 2 months FREE*
>http://join.msn.com/?page=features/junkmail
>
>_______________________________________________
>Chameleon mailing list
>Chameleon at lists.maptools.org
>http://lists.maptools.org/mailman/listinfo/chameleon
>
>
>_______________________________________________
>Chameleon mailing list
>Chameleon at lists.maptools.org
>http://lists.maptools.org/mailman/listinfo/chameleon

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail



More information about the Chameleon mailing list