Saturday, 9 January 2010

Flickr sets and groups on OSM


There are still a few flaws to sort out, but I've figured out how to extract KML files from Flickr groups as well as sets, how to provide either OSM or the Cycle map as a base, and how to embed the results. Results (so far) are below.


Jenkins quest set on OSM



Sustrans coast and castles set on Cycle Map



Sustrans Bristol & Bath group on Cycle Map





(Tues 12 Jan) Now slightly improved to avoid passing the KML file twice and offer alternative base map.

15 comments:

edgemaster said...

Are you doing a second explicit pass (the first will be in the OpenLayers.Layer.GML constructor) over the data file?

Ah, I see, its to get the centroid and bounds?
If you assign the layer to a variable, you'll be able to call the getDataExtent() function (http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.getDataExtent)
And from the extent, getCenterLonLat

Still leaves you having to read the title though...

edgemaster said...

I'm pretty sure it does have a feature to extract the file's metadata... It may not work with (the very ugly) GML layer type though. (OpenLayers.Vector is the intended method for this).

If not, it needs to be implemented, I'm pretty sure I considered it in my todo list when writing the GPX format for OpenLayers...

gom1 said...

Edgemaster - yes that why 2 passes. Avoiding it would be good, so I'll have a go tomorrow at understanding and following your suggestion.

This is all very new for me (programming since the days of Cobol, but Javascript is a bit new to me). Any pointers on how to get the title and description from the KML header without getting into XML parsing?

Chris Hill said...

Just thought you might like to know:
Your embedded maps are causing my Firefox to try to find a plugin to display the object, but it can't find a suitable plugin. I get the prompt each time I visit the page. The embedded objects just show their titles (I assume they should show miniature maps).

townmouse said...

I'm getting the same effect Chris Hill reports

gom1 said...

Chris Hill & Townmouse - Sorry about that - I think I've fixed it now in Firefox, but I'm still getting some problems in IE. I'm supposed to be working this afternoon though, so I will have to leave it till later. I'n definitely at the edge of my programming abilities here!!!

Thanks for your help though - can you let me know how it looks to you now please?

Chris Hill said...

The mini-maps appear properly now in FF3.0. They scroll and zoom as expected. Thanks.

Putting three maps on a page takes time to download, mostly, I think, because OpenLayers pulls down a lot of tiles in anticipation of scrolling, but on such a small map most of these tiles are never seen, so take time, bandwidth and server resource that is not needed. I wonder if there is a way to limit this with OL functions or parameters.

Nice work and something I'm interesting in using. Even a small map with a couple of pointers or photos would be very handy in a blog and, of course, shows off OSM nicely.

gom1 said...

Once I get this stabilised I plan to set up a "mini-page" that will be easy to embed. If you look at the embedded code you will see how it works now - just a web page with parameters for the KML URL and the background map. You are welcome to lift it, of course, but it might not be a good idea while it's still flaky. I have created a separate Perl programme to build the KML file from Flickr groups or sets. Again, probably too flaky to distribute just now.

townmouse said...

Looking good now on Firefox. A bit slow to get all its elements in place, but that could be our internet connection

gom1 said...

As edgemaster pointed out, I am not processing the KML file in the most efficient way, and I suspect that the IE glitch is in a related area. So when I get chance I hope I can address both. Meanwhile, thanks for the feedback.

Sam Roberts said...

How would I generate a kml file with all existing geotagged images and those added in the future from the Flickr Group: http://www.flickr.com/groups/ghostsigns ?

I really want to do a mapping of the group but at the moment I only seem to be able to pull down KML files of c.20-30 images at a time...

gom1 said...

Thanks for the question Sam. I have put together a Perl script that I've been using to pull data from Flickr groups. It's a bit of a dog's breakfast, but it works most of the time, and I'll be happy to provide a copy if it is any use to you. I'm afraid I don't have access to a server that would allow you to use it online.

In any case, I've been trying to use it on your ghostsigns group, and for some reason that I haven't fathomed yet it keeps falling over. If (when) I can fix that I'll send the KML file it generates.

Sam Roberts said...

Thank you for taking the time to give it a go. As a complete novice to this type of stuff any help is really appreciated. I would love to do something more dynamic using Google Maps and Flickr's APIs to build a bespoke platform but can't afford to pay a developer. The KML route seems the most viable alternative.

gom1 said...

Several months later we now have this

Sam Roberts said...

Love it, can it go global if people add geotagged images from around the world?