<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:"var\(--ff-mono\)";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:inherit;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:13.2pt;background:#F9F8F6;vertical-align:baseline">
<span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Hi, <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:13.2pt;background:#F9F8F6;vertical-align:baseline">
<span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">I use Mapserver with the Leaflet JS library and I want to display some attributes informations by clicking on the map.<br>
Therefore I use the GetFeatureInfo WMS request in order to return these informations.<br>
I managed to get the infos with the text/html format but I'd like to get a JSON response back in my browser, e.g :<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">{<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">    "value": [value_0],
 // I must precise I use GetFeatureInfo on a raster<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">}</span><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:13.2pt;background:#F9F8F6;vertical-align:baseline">
<span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">So I changed the wms_get_feature_info_formalist in the METADATA bloc of my mapfile :<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">"wms_getfeatureinfo_formatlist"
 "application/json"</span><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:13.2pt;background:#F9F8F6;vertical-align:baseline">
<span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Then, I edited my template as following to return the value of the pixel :<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR"><!-- MapServer Template
 --><o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">[value_0]</span><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">My GetFeatureInfo request is the one (see "application/json" specified
 in the </span><span style="font-size:10.0pt;font-family:"var(--ff-mono)",serif;color:#232629;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR">INFO_FORMAT</span><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"> parameter)<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;background:silver;mso-highlight:silver;mso-ligatures:none;mso-fareast-language:FR">http://IP/cgi-bin/mapserv?map=/var/www/html/mapfiles/test1.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&BBOX=465348.6282001531,5431156.607774916,697564.3201305186,5503160.28841955&SRS=EPSG:3857&WIDTH=1519&HEIGHT=471&LAYERS=layer1&STYLES=&FORMAT=image/png&TRANSPARENT=true&QUERY_LAYERS=layer1&INFO_FORMAT=application/json&X=766&Y=261</span><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm;mso-ligatures:none;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">But when I try the GetFeatureInfo request, my browser returns nothing
 (whereas it works with the text/html) and it downloads a file called "mapserv" with nothing inside :<br>
</span><span style="color:black"><a href="https://i.stack.imgur.com/GuVAe.png"><span style="font-size:11.5pt;font-family:"inherit",serif;color:blue;border:none windowtext 1.0pt;padding:0cm;mso-fareast-language:FR;text-decoration:none"><img border="0" width="259" height="72" style="width:2.7in;height:.75in" id="Image_x0020_1" src="cid:image001.png@01D9E6F5.C8B19EC0" alt="enter image description here"></span></a></span><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"><o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"><br>
I must explain I don't want to download a GeoJSON file but to return the content of a JSON response in my browser.<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Do you know how I could get my JSON response ? Is it possible to
 make it work ?<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Any help would be greatly appreciated, thanks !<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">--<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Julien H<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Back-end developper<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#F9F8F6;vertical-align:baseline"><span style="font-size:11.5pt;font-family:"Segoe UI",sans-serif;color:#232629;mso-ligatures:none;mso-fareast-language:FR">Forum des Marais Atlantiques<o:p></o:p></span></p>
</div>
</body>
</html>