[Chameleon] Set map size based on user's screen resolution?

Julien-Samuel Lacroix jlacroix at mapgears.com
Mon Mar 27 10:55:34 EST 2006


Hello,
The MapSize widget normally submit the page when changeMapSize() is 
called. So I'm not sure it is the right tool to use for you. However, 
the MapDHTML widget already have some variables you can set for this 
kind of modification. You may try to set somewhere outside a JavaScript 
function:
   gMapWiWidth = [$MAP_WIDTH|600$];
   gMapWiHeight = [$MAP_HEIGHT|450$];
   gMapDHTMLURL += 
'&nWidth='+gMapWiWidth+'&nHeight='+gMapWiHeight;alert(gMapDHTMLURL);
function myOnLoad()
{
   CWC2OnLoadFunction()
}

Julien

Jennifer Shanks wrote:
> Hello,
> 
> I've designed an application that works well for 1024 x 768 screens, but 
> has issues with 800x600 and 1280x1024 resolutions.  To solve these 
> problems, I'd like to set a map size and a stylesheet that is 
> appropriate to the user's screen resolution when the application is 
> loading.  I've tried one approach for doing this, but the timing is 
> wrong and I'm hoping that someone will have a better suggestion.
> 
> Here's what I've tried so far:
> 1.  Included a modified version of the MapSize widget in the app that 
> also switches the stylesheet when changing map size(see code below).
> 2.  Created a function (checkScreenSize) that checks the client screen 
> resolution and runs the changeMapSize function.
> 3.  Run checkScreenSize in myOnLoad()
> 
> The problem with this approach is the timing.  By putting 
> checkScreenSize in myOnLoad(), the page then loads a second time if the 
> map size and stylesheet are switched.  Is there a way that I can 
> dynamically set the map size before the application loads?
> 
> Thanks for any suggestions.  Also, if anyone has any general comments on 
> designing an application that works well for multiple screen 
> resolutions, I'd love to hear them.
> 
> Regards,
> Jennifer
> 
> 
> 
> 
> 
> function checkScreenSize() {
>  var screenW = screen.width;
>  var screenH = screen.height;
> 
>   if (screenW <=800) {
>         changeMapSize(300, 300);
>   } else if (screenW >= 1024 && screenW <1280) {
>         changeMapSize(410, 410);
>   } else if (screenW >= 1280) {
>         changeMapSize(600, 600);
>   }
>  }
> 
> function myOnLoad()
> {
>   // make sure to initialize CWC2 first
> 
>   CWC2OnLoadFunction();
>       checkScreenSize();
> 
> }
> 
> 
>         $szJsFunctionName = "changeMapSize";
>         $szFunction = <<<EOT
> /**
>  * {$szJsFunctionName}
>  * called when the mapsize value is changed.
>  */
> function {$szJsFunctionName}(height, width)
> {
>         curMapSize = getMapSize();
>         if (curMapSize[0] != width || curMapSize[1] != height )
>         {
>             {$this->mszHTMLForm}.SET_MAP_WIDTH.value = width;
>             {$this->mszHTMLForm}.SET_MAP_HEIGHT.value = height;
> 
>              if (width==300) {
>              setActiveStyleSheet('ginfomapsmall');
>              }
>              if (width==410) {
>              setActiveStyleSheet('ginfomapmedium');
>              }
>              if (width==500) {
>              setActiveStyleSheet('ginfomaplarge');
>             }
> 
>             {$this->mszHTMLForm}.submit();
>        }
>     return;
> }
> EOT;
> 
> 
> 
> 
> 
> ****************************
> Jennifer Shanks
> GreenInfo Network
> 116 New Montgomery, Suite 738
> San Francisco, CA 94105
> (415) 979-0343 x 306
> (415) 979-0371 FAX
> **GreenInfo has completely re-done our web site
> Go to: www.greeninfo.org
> 
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the Chameleon mailing list