[Mapserver-users] PHP/MapScript question: How to return values when map is clicked?

har mar shaz_bot42 at yahoo.com
Fri Sep 12 09:46:37 EDT 2003


--0-1068305568-1063374397=:9597
Content-Type: text/plain; charset=us-ascii

Thanks, that and the examples linked to helped.  However, I am running into an error wen I use getLayer or getLayerByName.  If I use getLayerByName it tells me it failed (getLayerByName failed for : state)
 
I have checked my .map file, and in my .map fil it is indeed called state
 
LAYER
  NAME state
 
However if I use $layer = $myMap->getLayer, I get the following error
 
Warning: [MapServer Error]: msQueryByPoint(): No matching record(s) found.
 
Yet I clicked in a state, so I would assume it would have to return the statename (and everything else in the dbf file) to me.  
 
I wonder what is going on.  
 
Thankyou
 
Har


Krung Saengpole <krung at cad.go.th> wrote:
use queryByPoint(...). But you have to convert point in image to georef and make a pointObj from it. e.g.

$point=ms_newPointObj();
$point->setXY(x_coordinate, y_coordinate);

if (@$layer->queryByPoint($point,MS_SINGLE,0) == MS_SUCCESS) {
$result = $layer->getResult(0);
$index = $result->shapeindex+1;
$dbf = dbase_open(DBF_FILE,0);
$arr = dbase_get_record($dbf,$index);
......

HTH
Krung

---------- Original Message ----------------------------------
From: har mar 
Date: Thu, 11 Sep 2003 13:05:26 -0700 (PDT)

>Hello,
> 
>I am displaying a shapefile that contains states as a GIF. I am not using javascript at all. When the user clicks on the map, I want to return the name of the state that was clicked, and some other information that is in the dbf file. How do I do this? I can get the x,y coords by having the GIF set as an input type. I assume I will have to convert them to georef coords. But I am unsure of what 'function' to use to get those results. Any help would be greatly appreciated. 
> 
>Cheers
> 
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>_______________________________________________
>Mapserver-users mailing list
>Mapserver-users at lists.gis.umn.edu
>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
>
>

_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
--0-1068305568-1063374397=:9597
Content-Type: text/html; charset=us-ascii

<DIV>Thanks, that and the examples linked to helped.&nbsp; However, I am running into an error wen I use getLayer or getLayerByName.&nbsp; If I use getLayerByName it tells me it failed (getLayerByName failed for : state)</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have checked my .map file, and in my .map fil it is indeed called state</DIV>
<DIV>&nbsp;</DIV>
<DIV>LAYER<BR>&nbsp; NAME state</DIV>
<DIV>&nbsp;</DIV>
<DIV>However if I use $layer = $myMap-&gt;getLayer, I get the following error</DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>Warning</STRONG>: [MapServer Error]: msQueryByPoint(): No matching record(s) found.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Yet I clicked in a state, so I would assume it would have to return the statename (and everything else in the dbf file) to me.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>I wonder what is going on.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>Thankyou</DIV>
<DIV>&nbsp;</DIV>
<DIV>Har</DIV>
<DIV><BR><BR><B><I>Krung Saengpole &lt;krung at cad.go.th&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">use queryByPoint(...). But you have to convert point in image to georef and make a pointObj from it. e.g.<BR><BR>$point=ms_newPointObj();<BR>$point-&gt;setXY(x_coordinate, y_coordinate);<BR><BR>if (@$layer-&gt;queryByPoint($point,MS_SINGLE,0) == MS_SUCCESS) {<BR>$result = $layer-&gt;getResult(0);<BR>$index = $result-&gt;shapeindex+1;<BR>$dbf = dbase_open(DBF_FILE,0);<BR>$arr = dbase_get_record($dbf,$index);<BR>......<BR><BR>HTH<BR>Krung<BR><BR>---------- Original Message ----------------------------------<BR>From: har mar <SHAZ_BOT42 at YAHOO.COM><BR>Date: Thu, 11 Sep 2003 13:05:26 -0700 (PDT)<BR><BR>&gt;Hello,<BR>&gt; <BR>&gt;I am displaying a shapefile that contains states as a GIF. I am not using javascript at all. When the user clicks on the map, I want to return the name of the state that was clicked, and some other information that is in the dbf file. How do I do this? I can get
 the x,y coords by having the GIF set as an input type. I assume I will have to convert them to georef coords. But I am unsure of what 'function' to use to get those results. Any help would be greatly appreciated. <BR>&gt; <BR>&gt;Cheers<BR>&gt; <BR>&gt;<BR>&gt;<BR>&gt;---------------------------------<BR>&gt;Do you Yahoo!?<BR>&gt;Yahoo! SiteBuilder - Free, easy-to-use web site design software<BR>&gt;_______________________________________________<BR>&gt;Mapserver-users mailing list<BR>&gt;Mapserver-users at lists.gis.umn.edu<BR>&gt;http://lists.gis.umn.edu/mailman/listinfo/mapserver-users<BR>&gt;<BR>&gt;<BR>&gt;<BR><BR>_______________________________________________<BR>Mapserver-users mailing list<BR>Mapserver-users at lists.gis.umn.edu<BR>http://lists.gis.umn.edu/mailman/listinfo/mapserver-users</BLOCKQUOTE><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software
--0-1068305568-1063374397=:9597--



More information about the mapserver-users mailing list