How can I render OpenStreetMap tiles on-the-fly using PHP? - php

ers, I need to render OSM tiles on-the fly using PHP without downloading the huge 23GB or so OSM dump. I found this, but it seems to be dead. :/ By the way, I don't want to store anything. If anyone has any ideas, thanks ;)
By the way, I'm using it for a web mapping application for the Nintendo DSi. (link)
PS. I know I could use the public OSM tile sever, but I hate the tile styles. :P

Your question is very vague.
Instead of using the full planet you can download any custom area you like by specifying a bounding box using either the regular API or the Overpass API. The latter also allows you to filter for specific data, for example highways. Or you can use a country extract.
Alternatively you can just use different tiles if you don't like the default style. There are many many pre-rendered OSM maps with different styles. For example Cloudmade offers a huge choice of different styles and you can even create your own one.
A third option is to look at one of the many other rendering applications for OSM.
And whether you are allowed to use the official tiles or not depends on the tile usage policy. Note that there are also (different) policies for tiles from different providers.

Related

How to make a PHP MySQL search by clicking on part of a country map image

I am making a search functionality of a website wherein there is an image of an australian map divided into different provinces. When the user clicks on the particular province, it should display the vehicles available in that area. I am not familiar with the most appropriate technique by which this could be accomplished.
Any ideas
You would probably want to use an HTML Image Map and have each region on the image map link to a page, like: region.php?regionId=5
Take a look at: http://www.w3schools.com/tags/tag_map.asp
There are several free tools which can help you draw the regions on the map, which will generate the HTML for you.
I suggest you to use SVG format for the map. Nowadays it is supported in all modern browsers. That way you can draw provinces in exact forms and even scale them if necessary. Each province can be drawn as a single SVG-path.
One of the features SVG supports is scripting and events, including clicks. Apart from this, as usual, all logic can be "passed" into JavaScript event handlers from PHP page generator, so you'll then get AJAX requests with proper parameters.
You can create an image map in dreamweaver.
http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822510a94ae8d65-7c15a.html
or use an online one such as this.
http://www.image-maps.com/
you can then use the href tag to pass in variables to a php page
href="map.php?regionID=5"

PHP and JS in order to manage and draw graphs

I have a project to draw relationships between different elements determined on a sheet.
When the user has finished making the plan, it can export it to a txt file that contains the links.
A bit like MS Visio but with only three or four elements draguable.
Does anyone have an idea of ​​this project using web languages ​​(php, js) ?
Thank you in advance.
I am not so sure of your question but if you want to draw graphs using php variables with javascript, then the html5 canvas is probably your best bet in terms or proffessionality with design and implementation.
Only downside is it is javascript only, and the user must have a browser that supports canvas.
Take a look at Raphael, you can make your users draw anything you want, export the structure as JSON,for example, and treat it with any language you want
Take a look at this Raphael example to see an interconnected graph

How to highlight areas in map with php?

I have a country map in .png format, I need to highlight specific states in this map dynamically using PHP. What's the best way to do this?
Thanks
You would need to create a list of all the points defining the polygon encasing each state, then use imagepolygon to fill in the appropriate polygons on the map image with some color.
Realistically you probably want to find a 3rd party library/component (i.e. Flash movie, JavaScript map and library, or PHP class designed for this) rather than writing it on your own from scratch. Highlighting a map isn't exactly a new problem and solving it again from scratch is tedious.
If you're talking about US States, I would recommend trying Google Maps, and the following links. I used them for the exact purpose you're talking about (votes by state) recently, and it worked great:
http://econym.org.uk/gmap/example_states2.htm
http://econym.org.uk/gmap/epoly.htm
http://econym.org.uk/gmap/states.xml

Custom maps/coordinates

I'm looking for a quick way to drop in a map for something like Minecraft into a pan/zoomable thing, with support for custom coordinates (like defining where is 0,0 or something)
Can't seem to figure this out with google maps, any ideas? I have tile pngs for multiple zoomlevels, I have coordinates, just no clue how to implement it.
There are several ways to get the look and feel of a map.
One huge graphic
In case you've got only one huge picture of the map that is maybe even over 100 MB in size, use the service Zoom.it. Although it's supported by Microsoft and therefore uses Silverlight (JavaScript support available as well, though), it's a handy service. Besides, the homepage also stores the automatically generated tiles and hence serves as a webhoster as well.
Several tiles at different zoom levels
In this case it's probably best to use the Google Maps JavaScript API V3. It helps you realise all your map plans. In your case you'd have to overlay your map on the real world map. To be honest, that does sound weird as all coordinates on your specific map are also related to a region on the map of our beloved planet Earth. However, it works like a charm. Should you need webspace to upload your huge map in advance, use a service like Wuala for this purpose.
All-in-one Map Generator
As you want to create a map of your Minecraft world, it's maybe best to directly use Tectonicus, a deep map renderer that also creates all required HTML pages to render your map using the Google Maps API. You can find an example map here.

Generating maps Dynamically

I am looking to generate transport maps in a style similar to the iconic London underground [tube] map.
These maps will change from time to time and many will be required so instead of drawing them up manually in inkscape [or similar] I am hoping to have them generated dynamically from a db or dataset.
Does anyone know if there is any library apis etc. out there that would help with this task, or any suggestions in general of how [or how not] to go about this ?
I am thinking svg's would be the best way to go with this, plus there may be need for basic interactivity down the line.
I am working in php so otherwise it's GDlib, ImageMagick ?
Thanks in advance.
.k
Well, the answer really isnt in how to use GD or ImageMagick, there are manuals for that. As for helper libraries, most libraries focus on graphing, anything else you will have to write yourself. Your best bet as a solution would be to have your admin interface generate the images when data in the backend changes and cache the images, since there's no reason to build the image every time someone accesses it.
For generating maps, i think your best bet would be defining stations with one or many 'lines' which determine some sort of indicator of relationship to the stations around, and an x,y. You'd probably only need to determine a 'parent' station since you're just drawing lines from a-b. That way you can position them in the same manner as they're typically rendered on the actual trains, use the lines and surrounding stations to draw mappings.
Doesn't sound like too difficult a problem. 3 tables:
stations [stationid,name,x,y,meta1,meta2],
placements [placementid,stationid,lineid,parentstationid],
lines [lineid,name,meta1,meta2,colour,etc].
SVG would be pretty good at this sort of thing, and you would avoid the whole image building and caching process, but be wary of browser support issues.
Sounds like a pretty interesting project though, good luck :)
One strategy I use when I need to generate graphs from data in a db is to extract the data in some kind of XML way (e.g. Oracle SQLX or Cocoon XSP/ESQL or eXist-db XQuery) and process it through an XSLT to generate SVG. Good old Cocoon is fine for this kind of job if you don't want to write any code (except the XSL of course ;-).
The SVG itself can be loaded in some graphic tools to reprocess.
These maps will change from time to
time and many will be required so
instead of drawing them up manually in
inkscape [or similar] I am hoping to
have them generated dynamically from a
db or dataset.
If I were in your shoes, the very first thing I'd do is try to prove that the Google Maps API won't work for your application. Then, maybe, prove that ArcGIS won't work. (Even if they don't work, they're widely used, and you get to add lines to your CV.)

Categories