Everything's possible... ;-)

You probably are running into a conflict between navigating by click and 
coordinate. I'd have to see the interface to be sure. But it is likely that you 
are telling the software to recenter 2 ways. MapServer gives priority to the 
click-based nav. You can fix this a couple of ways:

1) use a second form on the page for the coordinate nav so that no conflict 
exists, it might look like this in your template:

<form action="/cgi-bin/mapserv">
  <input type=text name=mapx> lon  <input type=text name=mapy> lat <input 
type=submit value="go">
  <input type=hidden name=map value="[map]">
  <input type=hidden name=scale value="[scale]">
  <input type=hidden name=layers value="[layers]">
</form>

The only problems with this approach is that the layers are set when the page 
loads so if the user changes them and then sets a point those changes are lost. 
Secondly, your design might not allow you to setup a second form like this.

2) when you submit the form, check the values of form vars called lat and lon 
using javascript and if they look valid then craft a call to mapserver using 
those values. Like so (assuming the form is named 'ms'):

function submitMe() {
  if(document.ms.lat.value && document.ms.lon.value)
    window.location.href = 
'/cgi-bin/mapserv?map=[map]&scale=[scale]&layers=[layers_esc]&mapxy=' + 
document.ms.lon.value + '+' + document.ms.lat.value;

  return true;  // submit as normal
}

This approach is the most flexible but requires javascript. I would use lat/lon 
for the form element names to avoid any conflct with standard MapServer 
parameter names.

This is off the top of my head but the code above should get you started.

Steve

>>> Chip Taylor <[EMAIL PROTECTED]> 10/27/05 9:10 AM >>>
I have a map with no scripting (all CGI-based with HTML) that I'd like to
provide a way for the user to enter a longitude and latitude in text boxes,
hit submit, and recenter the map with current layers, size, etc on the
supplied latitude and longitude.  I know that the CGI passes the variables
mapx and mapy that tells you where the current map is centered, but if I
create a textboxes with id's and names of mapx and mapy, after these are
filled in with the desired values and the form is submitted the map is not
centered on these coordinates.  What am I doing wrong?  Is what I want
possible?

Chip Taylor
Prepared Response, Inc. 
1127 Broadway Plaza, Suite 204
Tacoma, WA  98402
O 253.272.1730
M 253.948.2525
STATEMENT OF CONFIDENTIALITY
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify Prepared Response, Inc. immediately at (206)
223-5544 and destroy all copies of this message and any attachments.

Reply via email to