[Geomoose-users] Setting initial conditions

Brent Fraser bfraser at geoanalytic.com
Tue Apr 17 18:13:57 EDT 2012


Bob,

   Thanks for the info.  I did a little experimenting and found out that 
"a Service with a user input type pointing to a user extension with a 
setValue function" will indeed work.

So now I have a URL of
geomoose.html?call=set_combobox&option_id=1

and a service of:
<service name="set_combobox">
<input type="ga_set_combobox" name="option_id" value="0"/>
</service>

with a user extension function of:
     GeoMOOSE.Services.InputType.SetComboBox = 
OpenLayers.Class(GeoMOOSE.Services.InputType, {
         MAPBOOK_NAME: "ga_set_combobox",
          setValue: function(option_id) {
     // ----      TBD: Code to set combo box selection    -----
         }
     });

The Chrome debugger says option_id = 1 so I think I'm good to go...

I'm basking in the awesomeness of GeoMoose!

Best Regards,
Brent Fraser


On 4/17/2012 3:56 PM, Bob Basques wrote:
>
> Brent,
>
>
> It's not GeoMoose specific, but I did something similar with this 
> function I found via Google:
>
>
>         function gup( name )
>
>         {
>
>                 name = 
> name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
>
>                 var regexS = "[\\?&]"+name+"=([^&#]*)";
>
>                 var regex = new RegExp( regexS );
>
>                 var results = regex.exec( window.location.href );
>
>                 if( results == null )
>
>                         return "";
>
>                 else
>
>                         return results[1];
>
>         }
>
>
>         // Set center from request params
>
>         var pminx = gup( 'minx' );
>
>         var pminy = gup( 'miny' );
>
>         var pmaxx = gup( 'maxx' );
>
>         var pmaxy = gup( 'maxy' );
>
>         var time_idx1=gup ( 'time_idx1' );
>
>         time_idx1 = time_idx1.replace(/%20/g, " ");
>
>         var time_idx2=gup ( 'time_idx2' );
>
>         time_idx2 = time_idx2.replace(/%20/g, " ");
>
>         var veh_id=gup ( 'veh_id' );
>
>
> It works very similarly to PERL param parsing.  As you can see above, 
> I have it set up to pass 7 different values that are optionally used 
> to start up a page, like so: 
> /_http://pwultra5.ci.stpaul.mn.us/cp_tiles/OpenLayers/OL.AVL.report2.html?veh_id=2042&time_idx1=4/12/2012%206:00:00&time_idx2=4/13/2012%206:00:00_/ 
> <http://pwultra5.ci.stpaul.mn.us/cp_tiles/OpenLayers/OL.AVL.report2.html?veh_id=2042&time_idx1=4/12/2012%206:00:00&time_idx2=4/13/2012%206:00:00> 
>
>
>
> This may get you closer to your goal.
>
>
> bobb
>
>
>
>
> >>> Brent Fraser <bfraser at geoanalytic.com> wrote:
>
> Looks like I have a need to set an initial condition for my GeoMoose 
> v2.4 site based on URL request values (these URLs are presented in a 
> Django-generated page from a database query).
>
> There already are a couple of ways to set initial values in GeoMoose:
>
> 1. Specifying a Startup Service 
> (http://www.geomoose.org/howto/startup.html)
>
> geomoose.html?call=set_image&fid
>
>
>            
>
>  =10&;image_id=20
>
>
> 2. Bookmarks (hey, where's the Bookmark doc?)
>
> geomoose.html?extent=-2530013,127825
>
>
>        
>
>  88,-202
>
>
>      
>
> 8586,13213082&on=Icebergs/all
>
>
>
> But instead of the above scenarios, I want to call a JavaScript 
> function (in my user extension) to programmatically select an item in 
> the ZoomTo combo box, something like:
>
> geomoose.html?UX_call=set_combobox&a mp;imag
>
>
> e_id=20
>
>
> Note that I keep the id in the value tag of the combo box options:
> <option value="10">
>
> I'm thinking of adding some code to the end of "onLoadedMapbook" to 
> mimic the GeoMOOSE.startService call:
>
>     var args = OpenLayers.Util.getParameters();
>     if(args.call) {
>         GeoMOOSE.startService(args.call, args, true);
>     }
>
> something like:
>     var args = OpenLayers.Util.getParameters();
>     if(args.UX_call) {
>         eval(args.UX_call+'('+args+')');
>     }
>
> But perhaps a Service with a user input type pointing to a user 
> extension with a "setValue" function would work with a startupService...
>
> Maybe I'm making this too difficult.  Any advice?
>
> -- 
>
>
> Best Regards,
>
>
> Brent Fraser
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geomoose-users/attachments/20120417/89522a72/attachment.html


More information about the Geomoose-users mailing list