Talk:Google Maps Example

From OpenStreetMap Wiki
Jump to navigation Jump to search

Discuss Google Maps Example here:


Attribution done within a per-layer map control

Currently the v3 example doesn't show how to do attribution as a map control. It just writes the attribution underneath. That's OK but it's cheating a bit really, or at least I think we should be showing how to do it as a map control in our example here. It also good to show how to tie it to a particular layer being displayed. See how http://www.busitlondon.co.uk/ does it. TODO Poke around in their code, and figure out an elegant way to show this compactly within the example. -- Harry Wood 14:11, 25 January 2012 (UTC)Reply

extraneous CSS

The v3 example include too much extaneous CSS stuff. Sure it looks pretty and people may appreciate an example of that too, but in my opinion examples like this work better when they're pared down to the bare minimum. -- Harry Wood 14:11, 25 January 2012 (UTC)Reply

OSM + Satellite only?

Is it possible to omit the standard road map and instead have just OpenStreetMap with Google satellite view, or are the "Map" and "Satellite" options hardcoded?

--Roadsguy (talk) 02:59, 7 December 2016 (UTC)Reply

Recent changes in OSM have caused problem with this code

I've been using this code since at least 2010 with no major issues. But recently the maps being returned from OSM include tiles with the "403r Access Blocked" message. It goes away if I zoom in and out a bit, but I read and understood the information about the message and it's clear that I ought to fix my version of the code to send referer information.

It looks like my code has to set this up in such a way that the Google Maps code will pass it on, attached to all of the requests that it sends to OSM. However I don't understand how to configure referrer information because the requests are being sent from my app and not a website. Sure it's set up to look like a website but it doesn't have a URL. Perhaps I'm asking how to not look like a bot, but is there a way to fix this problem? Paul Clapham (talk) 01:54, 2 April 2026 (UTC)Reply

You get those error tiles because your usage does not comply with Tile Usage Policy of tile.openstreetmap.org. If possible, consider switching to a paid raster tile provider. If not, set a correct referrer policy for your website if you use a web browser. If you used that code in a dedicated application, you must set a proper HTTP User-Agent header identifying your application. Please note that websites loaded from file:// URLs might not work. --Nakaner (talk) 09:30, 2 April 2026 (UTC)Reply
I have now set a User-Agent header, at least I believe I have. It's been a long time since I worked with JavaScript. But that hasn't changed the situation, so it looks like I still have a referrer problem. My system looks like this: I have a Java application which manages a database which (among many other things) contains information about locations. It allows the user (me) to create a new location by clicking on a map, and to see the locations in a particular geographical area, and so on. Hence the use of OSM -- I could have used Google Maps with this setup, but their maps are loaded with way too much stuff. Anyway, the application uses some externally-sourced Java code which uses JNI to run a version of Microsoft Edge, which uses an HTML page to connect to the Google Maps APIs and bring back the tiles.
What I have so far in that HTML page is
<meta name="referrer" content="strict-origin-when-cross-origin">
<meta name="User-Agent" content="Birder's Notebook (contact paul.c.clapham@gmail.com")>
in the <head> of the web page I'm passing to the Google Maps code via Edge.
So it looks like in this design there is no referrer information available, similar to the file:// URL example which you mentioned. The Tile Usage Policy doesn't exactly say I have to supply a valid Referer header, since I don't have a web page, but it looks like things have changed since that policy was last updated.
So unless you think my existing setup can be salvaged to provide correct referrer information, it looks like the paid raster provider would be the way to go. My usage is so small, and it's personal use only, I'm sure I would qualify for a free account. Paul Clapham (talk) 22:25, 2 April 2026 (UTC)Reply