Upload KML file into database and display on OpenLayers Map - php

I want to create a simple form on my wordpress site so that people can upload KML files which will then be stored in the db and the route shown on on openlayers map - openstreetmap.
The project is for a hiking site for storing hiking routes.
Any docs for this/ forums / advice. I'm completely new to this map stuff.
Cheers
Andy

Here is an example of an openstreetmap with a kml overlay done in openstreetmap: http://maps.burningsilicon.net/
Before working through this example, I recommend to read some introductory documentation on openlayers, since its inner workings are not always trivial to understand.
Don't forget to put some restrictions on the uploaded kml files. You should either limit the size and/or the number of nodes, since the huge kml files generated by gps trackers can easily bog the browser down. Alternatively, you can also simplify the uploaded kml files with gpsbabel (http://www.gpsbabel.org/).
If this sounds too complicated to you, Google Maps might be an option.

I have to edit the OpenStreetMap in order to make my city map a bit better and implement an on-line itinerary system. I have a KML file with all the bus stops from my city and I would like to overlay it somehow in an OSM editor program, so that I can create the streets and crosswalks in OSM accordingly. Do you have any hint

I strongly recommend you to read this book: OpenLayers 2.10 Beginner's Guide 2011 By Erik Hazzard.
For a novice like you, this book offers a lots of documentations with appropriate example regarding KML file.
And for the database, you could use PostgreSQL 9.0. Just helping by. Good luck.

Related

How can I render OpenStreetMap tiles on-the-fly using 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.

Script I can buy to display attachments inline like slideshare

Are there any scripts that I can buy to display pdf, ppt, doc attachments on my site - inline, so users don't need to download them to view it.
I run a knowledgebase which contains various documents uploaded by users - so trying to find a way to make it easier for them to view the files before download.
Google document viewer may work - but the terms of service does not allow us to build a preview application like slideshare. Anything else anyone has used to do something like this?
Does your site run on wordpress ?
If yes,you can use the google doc embedder plugin.
I don't think there is presently any straightforward way to display, say, a .ppt in a browser; other than of course, converting it so as to be suitable for a flash player, or html5 player, as is SlideShare's case. I might however, be wrong on this.
SlideShare has a whole lot of document conversion architecture built on Amazon EC2 for the same. [Refer to this post on the SlideShare Engineering Blog].
Alternatively, there is Zoho Viewer - which is going to close down by the end of 2012. There was also PdfMeNot, but I don't think it exists anymore

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.

Google Maps Overlays

I'm trying to find something, preferably F/OSS, that can generate a Google Maps overlay from KML and/or KMZ data.
We've got an event site we're working on that needed to accommodate ~16,000 place markers last year and will likely have at least that many again this year. Last year, the company that had done the site just fed the KML data directly to the gMaps API and let it place all of the markers client side. Obviously, that became a performance nightmare and tended to make older browsers "freeze" (or at least appear frozen for several minutes at a time).
Ideally this server side script would take the KML, the map's lat/lon center, and the map zoom level and appropriately merge all of the visible place markers into a single GIF or PNG overlay.
Any guidance or recommendations on this would be greatly appreciated.
UPDATE 10/8/2008 - Most of the information I've come across here and other places would seem to indicate that lessening the number of points on the map is the way to go (i.e. using one marker to represent several when viewing from a higher altitude/zoom level). While that's probably a good approach in some cases, it won't work here. We're looking for the visual impact of a US map with many thousand markers on it. One option I've explored is a service called PushPin, which when fed (presumably) KML will create, server side, an overlay that has all of the visible points (based on center lat/lon and zoom level) rendered onto a single image, so instead of performing several thousand DOM manipulations client side, we merge all of those markers into a single image server side and do a single DOM manipulation on the client end. The PushPin service is really slick and would definitely work if not for the associated costs. We're really looking for something F/OSS that we could run server side to generate that overlay ourselves.
You may want to look into something like Geoserver or Mapserver. They are Google map clones, and a lot more.
You could generate an overlay that you like, and Geoserver(I think mapserver does as well) can give you KML, PDF, png, and other output to mix your maps, or you could generate the whole map by yourself, but that takes time.
Not sure why you want to go to a GIF/PNG overlay, you can do this directly in KML. I'm assuming that most of your performance problem was being caused by points outside the user's current view, i.e. the user is looking at New York but you have points in Los Angeles that are wasting memory because they aren't visible. If you really have 16,000 points that are all visible at once for a typical then yes you'll need to pursue a different strategy.
If the above applies, the procedure would be as follows:
Determine the center & extent of the map
Given that you should be able to calculate the lat/long of the upper left and lower right corners of the map.
Iterate through your database of points and check each location against the two corners. Longitude needs to be greater (signed!) than the upper left longitude and less than the lower right longitude. Latitude needs to be less than the upper left latitude (signed!) and greater than the lower right latitude. Just simple comparisons, no fancy calculations required here.
Output the matching points to a temporary KML for the user.
You can feed KML directly into Google Maps and let it map it, or you can use the Javascript maps API to load the points via KML.
It might not solve your exact problem here, but for related issues you might also look into the Google Static Maps API. This allows you to create a static image file with placemarkers on it that will load very quickly, but won't have the interactivity of a regular Google map. Because of the way the API is designed, however, it can't handle anywhere near 16,000 points either so you'd still have to filter down to the view.
I don't know how fare you are with your project but maybe you can take a look at GeoDjango? This modified Django release includes all kinds of tools to store locations; convert coordinates and display maps, the easy way. Offcourse you need some Python experience and a server to run it on, but once you've got the hang of Django it works fast and good.
If you just want a solution for your problem try grouping your results at lower zoom levels, a good example of this implementation can be found here.
This is a tough one. You can use custom tilesets with Google Maps, but you still need some way to generate the tiles (other than manually).
I'm afraid that's all I've got =/
OpenLayers is a great javascript frontend to multiple mapping services or your own map servers. Version 2.7 was just released, which adds some pretty amazing features and controls.

Categories