[Geomoose-users] Calling javascript from mapbook.xml, or change params with javascript

Brent Fraser bfraser at geoanalytic.com
Thu May 26 10:49:02 EDT 2011


Just a note for those trying to do the same thing.  Bob was successful 
when he changed his function name to be all lowercase.

Best Regards,
Brent Fraser


On 5/24/2011 8:34 AM, Brent Fraser wrote:
> Bob,
>
>   Have a look at http://www.geomoose.org/docs/user_extensions.html and 
> varoius pages on the wiki 
> (http://www.geomoose.org/wiki/index.php/Main_Page), and the functions 
> defined in the geomoose.js file.  The functions in the file are the 
> user-accessible "official" GeoMOOSE API.  These resources may give you 
> a few ideas.
>
> In one of my sites,  I needed to get the value of the selected item in 
> a combo box and use it for input value in services.
>
> My combo box is a little complicated; the important bits are 
> id="GA_SelectedImage" and the first part of the option value (1,2,3,etc)
>
> <div id="control-panel">
> <center>
>         Image:
> <select id="GA_SelectedImage" 
> onchange="GeoMOOSE.UX.registered_extensions.GA_ImageOps.prototype.zoomToImage(this.value);">
> <option value="">Choose Image:</option>
> <option 
> value="1:-2172034,13348962,-1027313,14456993:Landsat/p230r005_20010703">L7 
> 2001-07-03 p230-r005</option>
> <option 
> value="2:-2564614,12851203,-1468813,13863841:Landsat/p230r006_20010703">L7 
> 2001-07-03 p230-r006</option>
> <option 
> value="3:-2564614,12851203,-1468813,13863841:Landsat/p231r006_20010608">L7 
> 2001-06-08 p231-r006</option>
>
>
> I have a service called "add_polygon" (see the Feature Editor doc) 
> where one of the inputs is defined as "imageid":
>
> <service name="add_polygon">
> <input type="ga_get_imageid" name="feature:imageid" value="0"/>
>
>
> Note the type tag value refers to my custom input type.  And [I 
> think?] since its outside the the "<step>" tag it is not shown to the 
> user.  If I wanted to make it visible and changeable by the user I 
> could have done:
>
> <service name="add_polygon">
>
> <step type="input">
> <input type="ga_get_imageid" name="feature:imageid" value="0"/>
>
>
> I defined the type by creating a Javascript file in the extensions 
> folder containing:
>
> GeoMOOSE.Services.InputType.GetImageID = 
> OpenLayers.Class(GeoMOOSE.Services.InputType, {
>     MAPBOOK_NAME: "ga_get_imageid",
>
>      getValue: function() {
>         var selection = document.getElementById('GA_SelectedImage');
>         var theValue = selection.children[selection.selectedIndex].value;
>
>         var aParams = theValue.split(':');
>         var id = aParams[0];
>         return id;
>     }
> });
>
> And my JavaScript file is loaded in my main html page:
> <script type="text/javascript" 
> src="extensions/GeoAnalytic_Custom.js"></script>
>
> So basically, when the service is invoked, it processes the input 
> types, and calls the ga_get_imageid function.  The function finds the 
> combo box control, gets the selected value, and returns the important 
> part of the value.  GeoMoose sets the service's input type value to 
> that returned value and passes it to the target URL of the service.
>
> Somewhat complicated, but it separates my custom JavaScript from the 
> standard GeoMOOSE (making updates much easier).
> Best Regards,
> Brent Fraser
>
> On 5/23/2011 12:11 PM, Bistrais, Bob wrote:
>>
>> Hi,
>>
>> I'm looking to dynamically control some of the parameter values in 
>> mapbook.xml.  In a nutshell, I've been able to save a selected town 
>> name by holding it in a hidden input in index.html.  So what I'd like 
>> to do, in the search_parcels service, is to update a parameter with 
>> that town name.  I believe it would make use of some javascript, but 
>> I'm not quite sure how to do it.  Any suggestions?  Any more 
>> clarification needed?
>>
>>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
>
>
> _______________________________________________
> Geomoose-users mailing list
> Geomoose-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geomoose-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/geomoose-users/attachments/20110526/1819f9d0/attachment.html


More information about the Geomoose-users mailing list