Ok in case anyone's interested, here's how I solved the below problem:
My point theme is stored (in the shapefile) in LatLongs and so when I
loop through the features, I get bounding boxes ($bounds) in LatLongs.
My map however then gets projected into a different coordinate system
(ETRS-89 LCC) when its drawn.
So in order to get the map2click function to work, I needed to project
each bounding box (by using $bounds->project ) first and then run
map2click. Thanks for the code, Ace.
Hope this helps someone.
Stu
Stuart Eve wrote:
Hi all,
I'm trying to convert a geographic coordinate into a pixel value (i.e.
the reverse of the click2map demo script).
I have searched around and found Ace Suares' script:
function map2click ( $map, $bounds ) {
$bounds_average_x = ( $bounds->maxx + $bounds->minx ) / 2;
$bounds_average_y = ( $bounds->miny + $bounds->maxy ) / 2;
$x_pct = ( ( $bounds_average_x - $map->extent->minx ) / (
$map->extent->maxx - $map->extent->minx ) );
$y_pct = ( ( $bounds_average_y - $map->extent->miny ) / (
$map->extent->maxy - $map->extent->miny ) );
$x_map = intval( $map->width * $x_pct );
$y_map = intval( $map->height * (1 - $y_pct) );
return array( $x_map, $y_map );
}
But this doesn't seem to be working for me - it just returns a very
big negative number.
I am using a point theme - with the data stored in LatLongs.
Has anyone seen a script to do this?
Thanks in advance,
Stuart
--
Stuart Eve
L - P : Archaeology
[EMAIL PROTECTED]