Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Interactive Maps with PHP
The second file is ampliacion.php3 and its code looks like this:
<HTML>
<HEAD></HEAD>
<BODY bgcolor="#CCCCCC#">
<IMG SRC="zoom.php3?x=<? echo $mapa_x ?>&y=<? echo $mapa_y ?>">
</body>
</html>
Its function is to transmit the coordinates received from map.html to an interactive image called zoom.php3 and load it. Here, the coordinates are transmited by x and y variables.
The third file is zoom.php3 and it contains the code to generate the portion of map that you want to zoom. Here is the code:

<?php

Header
( "Content-type: image/gif");
$bigmap=ImageCreateFromGif("caligran.gif");
$image_out=ImageCreate(200,96);
$factor=3.75;
$posx=floor($x*$factor-100);
$posy=floor($y*$factor-48);
$copia=ImageCopyResized($image_out, $bigmap, 0, 0, $posx, $posy, 200, 96, 200, 96);
ImageGif($image_out);
ImageDestroy($bigmap);
ImageDestroy($image_out);

?>
I'm suposing that the size of the zoomed portion of map is the same as the small map (200x96). Remember that the size of the big map is 747x360, then if you divide 360 by 96 (or 747 by 200) the zoom factor is approximately 3.75.
$posx and $posy are the start coordinates from the big map, they are calculated by multiplying $x and $y by the zoom factor and then they are moved to ensure that the place where the user clicks in the small map goes to the center of the zoom map.
It is very important to realize that you cannot put any HTML tags in this file. Also, there should not be any spaces or blank lines before or after the <? and ?> tags. If you are getting a broken image using this script, chances are you have a stray carriage return somewhere outside the PHP tags.
Remember that your PHP setup needs support from the GD library.
You can obtain the map files by clicking on next links:
Cali is the city where I live. Its long name is Santiago de Cali
You can optimize this method making it recursive and having several zoomings with more than 2 images, or have the small and big maps in the same file.
--Pablo

[Page 1]  [Page 2]  


Comments:
RE: Performance with BIG images?Don Deskins07/11/07 13:27
how i use map in phpdinesh06/28/05 06:48
can't remove borderlakhbir06/20/05 07:59
No gif or jpg support?Stripe-man03/23/05 02:19
RE: Can't get this workingBen12/16/02 00:57
RE: Performance with BIG images?taeho10/20/02 07:54
RE: GIS systems - come see thisSinh Nguyen09/06/02 13:27
Can't get this workingJohn Guarino09/06/02 11:41
pixsel information azam09/02/02 11:07
magataperdrap06/21/02 21:59
Multiple selections?Joseph02/28/02 22:33
GIS systems - come see thisRagnvald Larsen01/30/02 17:43
RERE: Performance with BIG images? (to Steve)zulu11/21/01 10:22
RE: Drawing mapsGerardo Tasistro11/13/01 00:07
Drawing mapsDaniel11/11/01 06:22
RE: Performance with BIG images? (to Steve)Gerardo Tasistro11/05/01 21:10
Web PagesShankar10/24/01 06:26
images and htmljaydj09/14/01 00:07
RE: Performance with BIG images?James Smith06/12/01 02:26
successedy04/26/01 03:49
no image on 2nd pageedy04/19/01 01:08
Image zoomingR.Talis02/20/01 22:35
Image zoomingR.Talis02/20/01 22:32
RE: Performance with BIG images?Jose' L Landivar01/20/01 20:06
Performance with BIG images?Steve Beuret11/29/00 09:19
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.