Zoom to custom extent - PHP

William Bronsema wbronsema at DMSOLUTIONS.CA
Wed Jan 26 14:52:35 EST 2005


Kevin,

doQuickZoom is supposed to go back to "".  echo
$HTTP_FORM_VARS['doQuickZoom'] before your "If ( isset(
$HTTP_FORM_VARS['doQuickZoom'])...." statement to see what I mean.  It
should only echo 1 after a quick zoom is called.  You only want it to be 1
when you want to do a quick zoom.  Make sense?

Is the PHP code being called to perform the quick zoom and the map is just
not zooming?  Or is the PHP code not being called?

Regards,
Bill

________________________________________________
William A. Bronsema, C.E.T.
Applications and Software Development,
DM Solutions Group Inc.


> -----Original Message-----
> From: Kevin Grootendorst [mailto:kgrootendorst at BAIRD.COM]
> Sent: January 26, 2005 2:44 PM
> To: MAPSERVER-USERS at LISTS.UMN.EDU; William Bronsema
> Subject: Re: Zoom to custom extent - PHP
>
> Bill,
> Hopefully this will be the last question I have - I feel I am close to
> getting this now.  I followed your instructions - but the 'QuickZoom' is
> not working yet (my normal rosa tools and legend works though).
>
> Here's what I did:
>
> 1. added the OnChange command called QuickZoom() to the Select statement
> in
> my app_contents.php
>
> 2. added the QuickZoom() function (in app_contents.php)
>      - sets 'doQuickZoom' = 1
> 3. added the hidden variable (in app_contents.php)
>      - sets 'doQuickZoom' = ""
>
> Through error checking I noticed that the function is being called
> properly, and the variable is being assigned the value from the function.
>
> 4. added the 'if statement' to my app.php:
> If ( isset( $HTTP_FORM_VARS['doQuickZoom']) && $HTTP_FORM_VARS
> ['doQuickZoom'] == "1" )
> {
> set new extents..same code as before.
> }
>
> However, it seems that the 'doQuickZoom' does not retain it's value of 1,
> instead it becomes "" again (each time I select from the 'quickmap' list
> and page refreshes).
> Even if I hardcode the hidden variable 'doQuickZoom' to be 1, and select
> the 'quickmap', the mapextents do not change.
> Does this make sense?
>
> Kevin
>
>
>
>
>
> On Wed, 26 Jan 2005 11:58:12 -0500, William Bronsema
> <wbronsema at DMSOLUTIONS.CA> wrote:
>
> >Hi Kevin,
> >
> >From the code you sent me, I see that you have added extra <form></form>
> >tags around your select element.  You will need to remove those. (Perhaps
> >that's why moving the select element makes it work now?)
> >
> >Adding an onchange event should work fine.  As for re-selecting the
> chosen
> >quick zoom after the page has refreshed, there are many ways to do it, I
> >just build the option list in php.  Something like this:
> >
> >***************************************
> >$aszOpList = array('7120999,827999,7599999,1119999'=>'Lake Ontario',
> >'7200000,833270,7291840,894520'=>'Niagara (ON)');
> >$szOpList = '';
> >foreach ( $ aszOpList as $key=>$szOp )
> >{
> >    // determine selected
> >    $szTmpSelect = ( isset(  $HTTP_FORM_VARS['ViewRegion'] ) &&
> >                     $HTTP_FORM_VARS [' ViewRegion '] == $key ) ?
> >                        ' selected' : '';
> >    // add next option
> >    $szOpList.= '<option value="'.$key.'"'.$szTmpSelect.
> >        '>'.$szOp.'</option>';
> >}
> >*****************************************
> >
> >That will build your list (be sure to add all the items) each time and
> >select an item if you have zoomed to that extent.
> >
> >I do foresee another problem that you will have, that is each time you
> >refresh the page, it will attempt to do a quick zoom because there will
> >always be a value selected.
> >
> >Add a hidden textbox to signal a quick zoom request:
> ><input type="hidden" name="doQuickZoom" value="">
> >
> >In your onChange function set the value:
> >
> >document.forms[0].doQuickZoom.value = 1;
> >document.forms[0].submit();
> >
> >Then back in PHP only execute the quick zoom when doQuickZoom is set to
> 1:
> >
> >If ( isset( $HTTP_FORM_VARS['doQuickZoom']) &&
> >$HTTP_FORM_VARS['doQuickZoom'] == 1 )
> >{
> >        .....
> >}
> >
> >HTH
> >
> >Bill
> >______________________________
> >William A. Bronsema, C.E.T.
> >Applications and Software Development,
> >DM Solutions Group Inc.
> >
> >> -----Original Message-----
> >> From: Kevin Grootendorst [mailto:kgrootendorst at BAIRD.COM]
> >> Sent: January 26, 2005 11:36 AM
> >> To: MAPSERVER-USERS at LISTS.UMN.EDU; William Bronsema
> >> Subject: Re: Zoom to custom extent - PHP
> >>
> >> Hi Bill,
> >> The quick zoom seems to be working now, but the ROSA tools do not
> respond,
> >> nor does the legend/layer list.  I moved the code in the 'contents.php'
> >> to 'higher up' in the file (no longer at bottom).  Once I select the
> >> region
> >> from the dropdown list, and click refresh, the map zooms to where it
> >> should.  However, the list defaults back to the first option.  It would
> >> also be nice to implement an 'onchange' event, so that I don't have to
> use
> >> the refresh button to zoom to the region (I'm wondering when things do
> >> work, if adding a layer and refreshing will automatically zoom to the
> >> first
> >> extent in the 'View Region' drop down list).
> >>
> >> Kevin
> >>
> >>
> >> On Wed, 26 Jan 2005 07:29:44 -0500, William Bronsema
> >> <wbronsema at DMSOLUTIONS.CA> wrote:
> >>
> >> >Kevin,
> >> >
> >> >The javascript error is not preventing your map from zooming,
> something
> >> else
> >> >is.  There is likely some other PHP code that is resetting the extents
> >> after
> >> >your quick zoom code.
> >> >
> >> >The javascript error you are getting occurs because the function you
> >> listed
> >> >cannot find the hidden textbox called "QueryString".  Did you happen
> to
> >> >remove it or move it outside of the form called "main"?
> >> >
> >> >Send me your app off-list and I will take a quick look.
> >> >
> >> >Bill
> >> >________________________________________________
> >> >William A. Bronsema, C.E.T.
> >> >Applications and Software Development,
> >> >DM Solutions Group Inc.
> >> >
> >> >
> >> >> -----Original Message-----
> >> >> From: UMN MapServer Users List [mailto:MAPSERVER-
> USERS at LISTS.UMN.EDU]
> >> On
> >> >> Behalf Of Kevin Grootendorst
> >> >> Sent: January 25, 2005 2:52 PM
> >> >> To: MAPSERVER-USERS at LISTS.UMN.EDU
> >> >> Subject: Re: [UMN_MAPSERVER-USERS] Zoom to custom extent - PHP
> >> >>
> >> >> I've implemented the code, and now I'm even convinced it should
> work.
> >> But
> >> >> no such luck yet.  The debugging works just as it should, but when
> it
> >> >> should 'quick zoom now', the map still draws to the project's max
> >> extents.
> >> >> However, I do receive a windows js error box indicating a problem in
> >> the
> >> >> app.phmtl file:
> >> >>
> >> >> 'document.main.QueryString.value' is null or not an object.
> >> >>
> >> >>
> >> >> Here is my javascript from the .phtml file:
> >> >>
> >> >> <script language="javascript">
> >> >> window.resizeTo(1024,768);
> >> >> /**
> >> >>  * This function runs after the form is done loading
> >> >>  **/
> >> >> function doneLoading()
> >> >> {
> >> >>     // show the query results page if query
> >> >>     if ( document.main.QueryString.value != "" )
> >> >>     {
> >> >>         // complete the string
> >> >>         document.main.QueryString.value = "?PrevStateKey=" +
> >> >> document.main.PrevStateKey.value + "&INPUT_COORD=" +
> >> >> document.main.INPUT_COORD.value;
> >> >>
> >> >>         // calculate the center
> >> >>         if (document.all)
> >> >>             var xMax = screen.width, yMax = screen.height;
> >> >>         else if (document.layers)
> >> >>             var xMax = window.outerWidth, yMax = window.outerHeight;
> >> >>         else
> >> >>             //var xMax = 640, yMax=480;
> >> >>   var xMax = 800, yMax=600;
> >> >>         var xOffset = (xMax - 510)/2, yOffset = (yMax - 390)/2;
> >> >>
> >> >> //QUERY RESULTS WINDOW
> >> >>         // load the processing page
> >> >>         mapquery = window.open('query.phtml' +
> >> >>
> >>
> document.main.QueryString.value,'mapquery','scrollbars=yes,resizable=yes,w
> >> >> id
> >> >>
> >>
> th=800,height=600,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',
> >> >> le
> >> >> ft='+xOffset+'');
> >> >>
> >> >>         // give it focus
> >> >>         mapquery.focus();
> >> >>
> >> >>     }
> >> >>
> >> >>     // exit
> >> >>     return;
> >> >> }
> >> >>
> >> >> </script>
> >> >>
> >> >>
> >> >> Could this somehow be preventing my php code from working?



More information about the mapserver-users mailing list