[mapserver-users] mapserver+javascript without template example?!!!

Alan Boudreault aboudreault at mapgears.com
Mon Sep 10 04:46:02 PDT 2012


This is not related to mapserver. This is only html/form. There is no 
*substitution* of mapserver at all with this example.

Take a look at this documentation about html form: 
http://www.w3.org/TR/html401/interact/forms.html

Also, the reason why imxy input has some effect on the url sent is 
because it is missing its "end tag". See "value="[center]">" rather than
"value="[center]"/>"

Good Luck!

Alan

On 12-09-10 01:46 AM, Saka Royban wrote:
> Thanks for your help
> I changed my file to follows:
> </head>
>      <script language="JavaScript">
>          function zoom(){
> document.forms['mapserv'].submit();
>          }
>      </script>
> <body>
> <h1> A Dynamic Map </h1>
> <p></p>
> <h3> use form to make map dynamic + scripting </h3>
>      <form name="mapserv" method="get" action="/cgi-bin/mapserv.exe">
>          <input type="hidden" name="imgxy" value="[center]">
>          <input type="hidden" name="map" value="[map]" />
>          <input type="hidden" name="imgext" value="[mapext]" />
>          <input type="hidden" name="layers" value="[layers]" />
>          <input type="hidden" name="mode" value="map" />
>
>          <input type="hidden" name="zoomsize" value="2" />
>
>          <input type="image" name="img"
> src="http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/ms101/htdocs/ms101.map&layers=all&mode=map"
> onclick="zoom()"/>
>
>      </form>
>
> </body>
> <html>
>
> If i click on image, i get a response from mapserver correctly. In fact,
> in loading the above page, mapserver properly fills variables like
> [map]. This is the url after clicking map:
> http://localhost/cgi-bin/mapserv.exe?imgxy=400+200&map=%2Fms4w%2Fapps%2Fms101%2Fhtdocs%2Fms101.map&imgext=-180+-90+180+90&layers=[layers]&mode=map&zoomsize=2&img.x=228&img.y=108
>
> But when i remove <input type="hidden" name="imgxy" value="[center]">,
> mapserver does not substitutes any variable.
> this is the url after clicking map:
> http://localhost/cgi-bin/mapserv.exe?map=[map]&imgext=[mapext]&layers=[layers]&mode=map&zoomsize=2&img.x=618&img.y=160
>
> Why MapServer behaves like this? (useful for mentioning, there is no
> template defined in map file)
>
> ----- Original Message -----
> From: Alan Boudreault <aboudreault at mapgears.com>
> To: mapserver-users at lists.osgeo.org
> Cc:
> Sent: Monday, September 10, 2012 5:58 AM
> Subject: Re: [mapserver-users] mapserver+javascript without template
> example?!!!
>
> You should verify what exact request is sent to the server... I would
> assume something like "map=[map]" is sent. Use Firebug of any other
> debugging tool.
>
> Alan
>
> On 12-09-09 01:54 PM, Saka Royban wrote:
>  > Hi all.
>  > I'm just looking for some examples of using javascript with mapserver
>  > without using html templates.
>  > I know that there are some libraries around like OpenLayers, but i wanna
>  > see what happens in background first and then move to use these
> libraries.
>  > This is what i have written which does not works: (i get a error saying
>  > MS_DEFAULT_MAPFILE_PATTERN validation failed )
>  > <html>
>  > <head>
>  > </head>
>  >      <script language="JavaScript">
>  >          function zoom(){
>  >          document.forms['mapserv'].imgxy.value = "400 200";
>  >          document.forms['mapserv'].zoom.value = 2;
>  >          document.forms['mapserv'].submit();
>  >
>  >          }
>  >      </script>
>  > <body>
>  > <h1> A Dynamic Map </h1>
>  > <p></p>
>  > <h3> use form to make map dynamic + scripting </h3>
>  >      <form name="mapserv" method="GET" action="/cgi-bin/mapserv.exe">
>  >          <input type="hidden" name="imgxy" value="400 200">
>  >          <input type="hidden" name="map" value="[map]" />
>  >      <input type="hidden" name="imgext" value="[mapext]" />
>  >          <input type="hidden" name="imgxy" value="[center]" />
>  >          <input type="hidden" name="zoomsize" value="2" />
>  >
>  >          <input type="image" name="img"
>  >
> src="http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/ms101/htdocs/ms101.map&layers=all&mode=map"
>  > onclick="zoom()"/>
>  >
>  >      </form>
>  >
>  > </body>
>  >
>  > Thanks in advance
>  > <html>
>  >
>  >
>  > _______________________________________________
>  > mapserver-users mailing list
>  > mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>  > http://lists.osgeo.org/mailman/listinfo/mapserver-users
>  >
>
>
> --
> Alan Boudreault
> http://www.mapgears.com/
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>


-- 
Alan Boudreault
http://www.mapgears.com/


More information about the mapserver-users mailing list