473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dynamic Maps with php??

I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.

Craig
Jul 17 '05 #1
7 3694
On Tue, 12 Apr 2005 15:12:02 -0400, Craig Storey <cr*********@nrc.ca> wrote:
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.


Sounds like you basically need an image map. The old-style server-side image
maps rather than client-side maps may be the way to go, since these just pass
x/y coordinates of the click to the script. You can then look up the nearest
point or line to the click and add it to the route.

http://www.w3.org/TR/html401/struct/objects.html#h-13.6

Then with the GD functions (http://php.net/image) you should be able to
superimpose a route on a map.

It's a round-trip to the server for each click - this might be a little
annoying but it's simple and safe. You could get fancy with
JavaScript/XMLHTTPRequest type things to avoid roundtrips, but you probably
want to save that for version 2 :-)

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
Craig Storey wrote:
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.


Not really trivial, but may be easier than you think... hope you know
Flash & ActionScript....

Flash can send/retrieve values from PHP scripts in the background by
using the getURL/loadVariables methods (as well as using XML and the
like). Since Flash uses vector art, you can use it to zoom in-and-out of
parts of a map and such. I'd go into all the details here, but that's
the kind of thing I get paid for at work... ;)

That should be enough information to allow you to find the correct stuff
on Google to help you out. I won't plug my employer's name here, I'm not
fishing for projects right now, but if you need services, email me.

--
Justin Koivisto - ju****@koivi.com
http://koivi.com
Jul 17 '05 #3
Craig Storey wrote:
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.

Craig


You could try to do this with SVG graphics. If you can get your maps in an
SVG format. This also means you're visitors need an SVG plugin.
But it would be a kick-ass solution...

http://www.carto.net/papers/svg/links/
http://www.webreference.com/authoring/languages/svg/
http://kartoweb.itc.nl/public_examples/SVG/
http://www.w3.org/2004/Talks/1211-Twente-
http://www.adobe.com/svg/community/external.html

Rutger
--
Rutger Claes rg*@rgc.tld
Replace tld with top level domain of belgium to contact me pgp:0x3B7D6BD6
Do not reply to the from address. It's read by /dev/null and sa-learn only

Jul 17 '05 #4
"Craig Storey" <cr*********@nrc.ca> wrote in message
news:d3**********@nrc-news.nrc.ca...
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.


If you know Flash, then it's trivial. If not, then Javascript is probably a
easier option, as Flash is tricky, especially when you have to deal with
remoting.

I would do it like this:

1. Create two transparent gifs per trail, one showing it as selectable and
the other as selected. These images should be of the same size as the map.
2. Overlay all these images on the map, with the CSS visibility of the
selected ones set to hidden. The HTML will look something like this:

<div style="position: relative">
<img src="map.gif">
<img src="trail1_gray.gif" id="trail1"
style="position: absolute; left: 0; top: 0;">
<img src="trail1_red.gif" id="trail1_sel"
style="position: absolute; left: 0; top: 0; visibility: hidden">
<img src="trail2_gray.gif" id="trail2"
style="position: absolute; left: 0; top: 0;">
<img src="trail2_red.gif" id="trail2_sel"
style="position: absolute; left: 0; top: 0; visibility: hidden">
.... etc ...
</div>

3. On top of all these, overlay a blank transparent gif of the same size as
the map. This will be used for the image map.
4. Create a client-side image map for users to click on. Use polygon regions
to define clickable area near each trail. Attach an onclick handler to each
area. The HTML will look something like the following:

<map name="trails">
<area shape="polygon" coords="123,23,32,434,45,342"
onclick="return ToggleTrail(1)" title="Trail 1">
<area shape="polygon" coords="231,232,332,34,35,142"
onclick="return ToggleTrail(2)" title="Trail 1">
.... etc ...
</map>
5. In the Javascript handler toggle between the selectable and selected
image by setting the CSS visibility to hidden/visible. Save the selection
somewhere. The code will look something like this:

function ToggleTrail(num) {
if(selected[num]) {
document.getElementById('trial' + num).style.visible = 'visible';
document.getElementById('trial' + num + '_sel').style.visible =
'hidden';
selected[num] = false;
}
else {
document.getElementById('trial' + num).style.visible = 'hidden';
document.getElementById('trial' + num + '_sel').style.visible =
'visible';
selected[num] = true;
}
}
6. When the user press submit, saved the selections into a hidden element
and post the form.

Obviously you will need to add code that checks whether the trails are
actually connected.
Jul 17 '05 #5
Craig Storey wrote:
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.

Craig

Hi,
Thanks for all the great ideas!

Craig
Jul 17 '05 #6
Hi,

I have been working on a GIS for several years. I was using a ready-made
framework for it. The learning curve of a framework is often seen as a
downside, but imho if you actually need to learn about something as
complex as GIS, the opportuninty the framework offers you to learn by
looking into existing code and trying out the examples rather is an
advantage. Without the framework i would have needed much more time to
get into GIS programming.

Unfortunately this framework was Smalltalk, so it won't be much good for
php. So I agree with Rutger that you should try out SVG. Mainly because
i think it is the eayest way to learn about the graphics technology you
will need to handle those x, y coordinates from clickable maps. I don't
think SVG is ALL you need, i think you will need to build some sort of
server side representation of those graphics and things like 'trails' in
php too. I suggest you use an object oriented domain model, like the
ones used by phpPeanuts. But to know what these models should actually,
well, MODEL, SVG is a great place to start.

One other tip: The new version of MySQL has GIS extensions. These will
also help you with the server side model, and at the same time they may
boost the performance of your server side code dramatically.

If you need more advice or help, please let me know.

Greetings, succes,

Henk Verhoeven,
www.phpPeanuts.org.

BTW, for the same reason i think the learning curve of phpPeanuts is
actually an advantage if you want to learn somthing as complex as OOP ;-)

Rutger Claes wrote:
Craig Storey wrote:

I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they
select their hiking routes using drop lists or checkboxes containing the
names and numbers of the trails. If the route is simple the form takes
1-2 minutes to fill in, if it involves lots of tiny sections it can
become tedious to search for every trailname and may take 20 minutes.
Because of this they have asked for a map, rather than lists, and want
to open the application to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear
it isn't.

Craig

You could try to do this with SVG graphics. If you can get your maps in an
SVG format. This also means you're visitors need an SVG plugin.
But it would be a kick-ass solution...

http://www.carto.net/papers/svg/links/
http://www.webreference.com/authoring/languages/svg/
http://kartoweb.itc.nl/public_examples/SVG/
http://www.w3.org/2004/Talks/1211-Twente-
http://www.adobe.com/svg/community/external.html

Rutger

Jul 17 '05 #7
Take a look at www.mountainviews.ie which uses dynamic maps built from php,
sql, image-maps, GIS, SRTM data etc.

"Craig Storey" <cr*********@nrc.ca> wrote in message
news:d3**********@nrc-news.nrc.ca...
I have a little php application to store day hiking trips and to keep a
running total of their yearly trips for a few users. Currently they select
their hiking routes using drop lists or checkboxes containing the names and
numbers of the trails. If the route is simple the form takes 1-2 minutes
to fill in, if it involves lots of tiny sections it can become tedious to
search for every trailname and may take 20 minutes. Because of this they
have asked for a map, rather than lists, and want to open the application
to the public. Hmmm..

So I'm looking to create an application where users can select their
routes, by somehow selecting lines on a map, then somehow pass this to a
php script to process.

Suggestions on how to do this are invited. I hope it's trivial, I fear it
isn't.

Craig

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: piyush | last post by:
All, Has any one try creating maps with dontnet - dynamically while serving on the web? E.g. if I have maps of different counties and I want to construct a map of the state using county maps -...
1
by: Steve Bishop | last post by:
I don't know if there is such a thing, but when an image swaps, can you have different image maps on it dynamically? I have product pictures with several part numbers also wihin the picture. I...
3
by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap....
15
by: WHY | last post by:
Since there's no way to create a c# method with optional, or nullable parameters. And since you can't write an overloaded web method. Is it possible to edit the WSDL in conjunction with a c#...
1
by: code | last post by:
Hi Grp http://www.books-download.com/?Book=1493-PHP+Hacks+%3a+Tips+%26+Tools+For+Creating+Dynamic+Websites+(Hacks) Description Programmers love its flexibility and speed; designers love its...
1
by: george | last post by:
Hi, I have an app that takes data from a db and maps it to a CSV file. There are multiple maps for different customers which has different formatting rules. For example, some customer wants...
0
by: Hemanth | last post by:
Hello, I'm generating a dynamic image on a website (using php.net/image library) and I want add hyperlinks to certain locations on the image - similar to HTML image map. Could someone pls...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.