NaN results for itemquery with Dbox

Richard Greenwood richard.greenwood at GMAIL.COM
Wed Mar 21 19:16:57 PDT 2007


On 3/20/07, william paul <williampaul28 at yahoo.com> wrote:
> Hi:
>
> I am using Dbox and the example provided by Rich Greenwood, to map the
> results from a database query. I have modified the script so you can change
> the queryfile, qitem and qstring. The script works OK on 1 layer, but for
> others I get NaN. Before to map the results I test ( alert(qlayer, qitem,
> qstring)) to see if the queryfile, qitem and qstring are correct. Even
> though I have the core ct names for each one I still get NaN results
> What could be the problem?
>
> script from the database query results
> <script type="text/javascript" language="javascript">
> var qlayer = "anyQlayer";
> var qitem = "anyQitem";
> function map(qstring)
> {
> opener.itemQueryModified(qstring, qitem, qlayer);
> window.close();
> opener.focus();
> }
> </script>
>
>
> modified itemQuery script
>  ms.itemqueryoptions = "&mapext=shapes&savequery=true&";
>  function itemQueryModified(qstring, qitem, qlayer)
>  {
>   //ms.setLayer(qlayer, true);
>   var uri = ms.mapserver + '?map=' + ms.mapfile + "&layers=" +
> ms.getLayers("+") + "&mapsize=" + ms.width + "+" + ms.height;
>   uri += ms.itemqueryoptions;
>   uri += '&mode=itemquery'
>   uri += '&qlayer=' + qlayer;
>   uri += '&qitem=' + qitem;
>   uri += '&qstring=' + qstring;
>        var response = get_content(uri);
>        var tokens = response.split(',');
>   alert(qstring + qitem + qlayer + ", " + Number(tokens[1]),
> Number(tokens[2]), Number(tokens[3]), Number(tokens[4]));
>        ms.setExtent(Number(tokens[1]), Number(tokens[2]), Number(tokens[3]),
> Number(tokens[4]));
>        main.setImage(tokens[5]);
>        ms.savedqueryfile=tokens[6];
>   domouseclick('pan');
>  }

You probably didn't get a match in your database. NaN means "Not a
Number". MapServer did not return an extent for the selection because
it could not find anything, and so your browser was not able to
convert the tokens 1-4 into numbers.

I try to catch that and tell the user something like "no results found".

Rich

-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com



More information about the MapServer-users mailing list