V5 and OpenStreetMeap

Q&A about the latest versions
Post Reply
HaraldJ
Posts: 156
Joined: Wed Oct 10, 2012 2:05 pm
Location: Surrey, United Kingdom
Contact:

In version 4 is was not a big deal to use OpenStreetAmp instead of Google Maps. The mechanism that worked well in V4 doesn't seem to work any more, the code to replace is no longer in the HTML file.

Is there a way to use OpenStreetMap, Bing Maps, or any other provider, with version 5?

Thanks!

Harald
Harald Joergens
Harald Joergens Photography
Nutfield, Surrey, United Kingdom
User avatar
Hopki
Gnome
Posts: 13032
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi Harald,
Version 5 has the maps in the skin rather then the HTML page.
Publish the project with the map, then open the skin.js file.

You need to find

Code: Select all

var mapOptions = {
and replace the whole block with

Code: Select all

var mapOptions = {
				zoom: 14,
				center: activeNodeLatLng,
				streetViewControl: false,
				mapTypeId: "OSM", 
				mapTypeControlOptions: { mapTypeIds: ["OSM"] }
			}
then you have a line similar to

Code: Select all

me._map_1.ggMap = new google.maps.Map(me._map_1, mapOptions);
and after that you add

Code: Select all

me._map_1.ggMap.mapTypes.set("OSM", new google.maps.ImageMapType({
                getTileUrl: function(coord, zoom) {
            		return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
			//		return "http://otile1.mqcdn.com/tiles/1.0.0/osm/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
			//		return "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/" + zoom + "/" + coord.y + "/" + coord.x + ".png";
                },
                tileSize: new google.maps.Size(256, 256),
                name: "OpenStreetMap",
                maxZoom: 18
            }));
Regards,
Hopki
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
HaraldJ
Posts: 156
Joined: Wed Oct 10, 2012 2:05 pm
Location: Surrey, United Kingdom
Contact:

Hi Hopki,

Thank you very much, that's fabulous!!!

Of course it's a pain to manually edit the code every time output is generated. I'm using (on Windows), a free tool called "Find and Replace".

It can not only do what the name says, it can create command line code as well.
I copy and paste the command line code into a batch file, "ReplacerV5.bat". Then, after generating output with V5, I just have to double-click on that batch file, and all the changes are made by the batch file.

Harald
Harald Joergens
Harald Joergens Photography
Nutfield, Surrey, United Kingdom
User avatar
Hopki
Gnome
Posts: 13032
Joined: Thu Jan 10, 2008 3:16 pm
Location: Layer de la Haye, Essex UK
Contact:

Hi,
There are plans for this in the future, but for now, you need to add it manually.
Regards,
Hopki
Garden Gnome Support
If you send an e-mail to support please send a link to the forum post for reference.
support@ggnome.com
https://ggnome.com/wiki/documentation/
Post Reply