GCA Google maps with OpenStreetMap option

Discussion about the Geocaching Australia web site
Post Reply
User avatar
Nilbog_Aus
650 or more caches found
650 or more caches found
Posts: 102
Joined: 12 June 06 7:48 pm
Location: Wahroonga, NSW
Contact:

GCA Google maps with OpenStreetMap option

Post by Nilbog_Aus » 05 July 09 9:11 pm

I was playing with mapping layers at work (trust me it was more interesting than the coding I was supposed to be doing :) ) and I came across incorporating OSM maps into Google maps. http://wiki.openstreetmap.org/wiki/Usin ... n_web_site

So I wondered if it was something that could be added to the GCA Google maps?

I know the GCA developer are probably busy with the site move but I was hoping it could be something maybe added to the wish list.

User avatar
CraigRat
850 or more found!!!
850 or more found!!!
Posts: 7015
Joined: 23 August 04 3:17 pm
Twitter: CraigRat
Facebook: http://facebook.com/CraigRat
Location: Launceston, TAS
Contact:

Post by CraigRat » 05 July 09 9:33 pm

I'll look in to that.

I've done a LOT of OSM work in my region, and am a fan of the project.

User avatar
Nilbog_Aus
650 or more caches found
650 or more caches found
Posts: 102
Joined: 12 June 06 7:48 pm
Location: Wahroonga, NSW
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by Nilbog_Aus » 24 August 09 1:54 pm

More playing with slippy maps on my part and I have figured out some javascript code to show OSM tiles with the Google Maps API.

Code: Select all

var copyOSM = new GCopyrightCollection("<a href=\"http://www.openstreetmap.org/\">&copy; OpenStreetMap</a> (and) contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>");
copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, " "));

var tilesMapnik = new GTileLayer(copyOSM, 1, 17, { tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png' });
var tilesOsmarender = new GTileLayer(copyOSM, 1, 17, { tileUrlTemplate: 'http://tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png' });

var mapMapnik = new GMapType([tilesMapnik], G_NORMAL_MAP.getProjection(), "OSM");
var mapOsmarender = new GMapType([tilesOsmarender], G_NORMAL_MAP.getProjection(), "OSMtah");

map.addMapType(mapMapnik);
map.addMapType(mapOsmarender);
http://users.tpg.com.au/brind1/tpgmap.htm is my current effort for something else I am working on. The address field on this link only updates the map when you click outside the address field. This makes more sense in the context of the project I wrote it for.

Having a quick look at the GCA code I hope it should just be a matter of adding my code snippet to the showmap functions in the GCA JavaScript.

User avatar
CraigRat
850 or more found!!!
850 or more found!!!
Posts: 7015
Joined: 23 August 04 3:17 pm
Twitter: CraigRat
Facebook: http://facebook.com/CraigRat
Location: Launceston, TAS
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by CraigRat » 24 August 09 2:06 pm

Hey, thanks for that (I'd forgotten about this ... :oops: )

I'll have a play and see if it works!

User avatar
CraigRat
850 or more found!!!
850 or more found!!!
Posts: 7015
Joined: 23 August 04 3:17 pm
Twitter: CraigRat
Facebook: http://facebook.com/CraigRat
Location: Launceston, TAS
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by CraigRat » 24 August 09 2:27 pm

Seems to work. I've added it to the cachers gmaps and to the query gmap functions.

Thank you for your contribution (every bit helps!)

I've credited this change to you in the source and also in our SVN Repository.

User avatar
caughtatwork
Posts: 17015
Joined: 17 May 04 12:11 pm
Location: Melbourne
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by caughtatwork » 24 August 09 2:30 pm

Yay! Blame someone else :-)

User avatar
Nilbog_Aus
650 or more caches found
650 or more caches found
Posts: 102
Joined: 12 June 06 7:48 pm
Location: Wahroonga, NSW
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by Nilbog_Aus » 24 August 09 8:48 pm

Wow that was quick. Thanks!
caughtatwork wrote:Yay! Blame someone else :-)
Don't worry I have found there is always enough blame to go around all the developers no matter how big the group. :)

User avatar
caughtatwork
Posts: 17015
Joined: 17 May 04 12:11 pm
Location: Melbourne
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by caughtatwork » 24 August 09 8:53 pm

Actually, I think they're great.
Thank you very much for allowing us to steal your code.
What's the difference between OSM and OSMtah?

User avatar
Nilbog_Aus
650 or more caches found
650 or more caches found
Posts: 102
Joined: 12 June 06 7:48 pm
Location: Wahroonga, NSW
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by Nilbog_Aus » 25 August 09 12:58 am

I meant for OSM to stand for "Open Street Map". These map tiles are created weekly-ish on the open street map servers.

I meant for OSMtah to stand for "Open Street Map Tiles @ Home". These map tiles are created much more often based on each tiles usage. Although these map tiles are still served from a central server they are created by a distributed volunteer network, similar to SETI@Home or Folding@Home.

I tend to use both these two. I prefer the fonts and style of OSM but sometimes Tiles@Home is more up to date.

The great thing about OSM data is that it is open source. This means not only can anyone update the data behind the maps but anyone can generate maps off the data. This means cool things like Tiles@Home and opencyclemap are possible.

It's probably clear by now I'm a big fan of OSM. Hopefully having OSM maps on GCA will encorage people to update the OSM maps and make them even better.

User avatar
Nilbog_Aus
650 or more caches found
650 or more caches found
Posts: 102
Joined: 12 June 06 7:48 pm
Location: Wahroonga, NSW
Contact:

Re: GCA Google maps with OpenStreetMap option

Post by Nilbog_Aus » 18 April 12 3:09 pm

Given OSMtah is no more (link) I thought it might be worth updating my little javascript contribution.

Since I wrote the current script Open Cycle Map have confirmed their position in favour of third party use of their tiles. (link)

Updated code snippet below should change the map option from OSMtah to OCM.

Code: Select all

var copyOSM = new GCopyrightCollection("<a href=\"http://www.openstreetmap.org/\">&copy; OpenStreetMap</a> (and) contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>");
copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, " "));
var copyOCM = new GCopyrightCollection("<a href=\"http://www.opencyclemap.org/\">&copy; OpenCycleMap</a>, <a href=\"http://www.openstreetmap.org/\">&copy; OpenStreetMap</a> (and) contributors, <a href=\"http://creativecommons.org/licenses/by-sa/2.0/\">CC-BY-SA</a>");
copyOCM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, " "));

var tilesMapnik = new GTileLayer(copyOSM, 1, 17, { tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png' });
var tilesOCMrender = new GTileLayer(copyOCM, 1, 17, { tileUrlTemplate: 'http://tile.opencyclemap.org/cycle/{Z}/{X}/{Y}.png' });

var mapMapnik = new GMapType([tilesMapnik], G_NORMAL_MAP.getProjection(), "OSM");
var mapOCMarender = new GMapType([tilesOCMrender], G_NORMAL_MAP.getProjection(), "OCM");

map.addMapType(mapMapnik);
map.addMapType(mapOCMarender);

Post Reply