By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

geographical coordinates

P: n/a
Hello,

I've some geographical coordinates and I'd like to put them on a map.

Example: I've the map of the USA. Once I've selected Chicago, I'd like a
point-cross or what ever, on the Chicago point over the map.

How can this be done in PHP ?

I know you can do everything in GD, but does something similar already exist
?

Bob

Jun 30 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Message-ID: <44***********************@news.sunrise.ch> from Bob Bedford
contained the following:
Example: I've the map of the USA. Once I've selected Chicago, I'd like a
point-cross or what ever, on the Chicago point over the map.

How can this be done in PHP ?

In image , as an input type will return the coordinates of the point
clicked. I think the simplest way would be with an absolutely positioned
transparent .gif, positioned according to the co-ordinates returned.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 30 '06 #2

P: n/a
The way that I suppose is to use on of the form elements which is
called (input, type=image)
this element is considered as an image button, it allows you to click
on it (on the image) and then with submitting the form it submits the
coordinates of the image you are using

you can use it this way:
<form name="form1" method="get" action= "cityInfo.php" >
<input name="img" type="image" src="yourMap.jpg" >
</form>

On cityInfo.php page write the following:
$x = $_GET[img_x];
$y = $_GET[img_y];

By this way $x and $y will contain the coordinates of the exact point
that the user had clicked on it (in pixels of course)

I hope this will be what you needed

Jul 1 '06 #3

P: n/a
Tom
Have you looked into the Google Maps API?

http://www.google.com/apis/maps/

Tom
Bob Bedford wrote:
Hello,

I've some geographical coordinates and I'd like to put them on a map.

Example: I've the map of the USA. Once I've selected Chicago, I'd like a
point-cross or what ever, on the Chicago point over the map.

How can this be done in PHP ?

I know you can do everything in GD, but does something similar already exist
?

Bob


Jul 1 '06 #4

P: n/a

"Tom" <kl******@gmail.coma écrit dans le message de news:
11**********************@d56g2000cwd.googlegroups. com...
Have you looked into the Google Maps API?

http://www.google.com/apis/maps/
Thanks for the info. Unfortunately, we think that google map will be a
paying service soon, so we don't want to create such service then have to
stop it because GoogleMap becomes paying.

Also What we need is exactly show a point on a map, not detect where the
user clicked.

Thanks for your message.

Jul 2 '06 #5

P: n/a
Message-ID: <44***********************@news.sunrise.chfrom Bob Bedford
contained the following:
>Also What we need is exactly show a point on a map, not detect where the
user clicked.
Umm...why are they not the same?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 2 '06 #6

P: n/a
Umm...why are they not the same?
>
Cos he's got the latitude and longlitude and wants to convert that to
xy coords.
I am assuming that the lat/long is derived from a data source.

You need to convert that into xy coords for your map.

I would do this:-

Determine the lat/long of top-left and bottom-right of the map
Determine the width and height of the map in pixels

work out the xy coords by calculating degrees east and south of the
top-left corner. If you need minutes and seconds, remember you are
working in base 60!!!

display the main map in a <DIV>

Display the coordinate marker in another <DIVand position it relative
to the map DIV using and in-line style sheet; setting up the horizontal
and vertical offsets using PHP. If you are putting up more than one
marker you may need to manage the layer order of the DIVs as well.

This should display the map reference in the right place but you would
not be able to right click and save image as, because it is actually
two images..

frothpoker

Jul 4 '06 #7

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bob Bedford wrote:
Example: I've the map of the USA. Once I've selected Chicago, I'd like a
point-cross or what ever, on the Chicago point over the map.

How can this be done in PHP ?
With a clever mix of CSS and absolute positioning.

Let's suppose you have a HTML element (e.g. an <divtag with the map
inside) with known widht and height, and it is positioned relatively to the
document flow.

Then, a small <imgcontaining a crosshair or whatever. You only have to
position it absolutely (where "absolute" means "relative to the top-left
corner of the first parent having absolute or relative positioning"), and
specify top anf left offset.

Try something like this:

<div class='container' style='position:relative; width:500px;
height:300px;'>
<img src='map.png' style='width:500px; height:300px;'/>
<img src='crosshair.png' style='position:absolute; left:129px; top:72px;'/>
</div>

After you have tested t works in the major browsers, then replace the offset
with the required values to put the crosshair in the desired place. I
suppose you know how to do that with PHP.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEqlkm3jcQ2mg3Pc8RAu+3AJsFaRq7GXa95in0V2WLHF Jwtsq8UACfaM4t
QsAQh1B1og+MFukq5ZDdqkQ=
=kSY0
-----END PGP SIGNATURE-----
Jul 4 '06 #8

P: n/a
Hello,

on 07/02/2006 06:23 AM Bob Bedford said the following:
"Tom" <kl******@gmail.coma écrit dans le message de news:
11**********************@d56g2000cwd.googlegroups. com...
>Have you looked into the Google Maps API?

http://www.google.com/apis/maps/
Thanks for the info. Unfortunately, we think that google map will be a
paying service soon, so we don't want to create such service then have to
stop it because GoogleMap becomes paying.
No, the Google Maps API is free for sites freely accessible to their users.

For premium (paying) sites or enterprise sites (sites only available in
a intranet) there is the Enterprise Google Maps.

http://maps.google.com/support/bin/a...y?answer=26392

Also What we need is exactly show a point on a map, not detect where the
user clicked.
If you think you can use Google Maps API, you may want to try this forms
generation class that comes with plug-in for showing Google Maps in your
site.

http://www.phpclasses.org/formsgeneration

Even if you just want to show a read only map, it simplifies the
generation of the all the map HTML and Javascript to point any locations
you want and for instance make them show an information window like for
instance in this example of the map of the PHP user groups in the United
States.

http://www.phpclasses.org/browse/gro...ry/country/us/

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Jul 8 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.