Using OpenStreetMap (direct)
On non-web platforms, the inadequately identified requests to the public OpenStreetMap tile servers are blocked
Due to excessive usage, requests where the 'User-Agent' header is inadequately set have been blocked by the OpenStreetMap Foundation (who operate the tile servers).
The UA can be set through the TileLayer.userAgentPackageName argument (or manually).
If this is either unspecified or set to a generic string (like 'com.example.app'), then requests will return a blocked tile.
This does not apply to the web, where the UA cannot be set differently to what is provided by the browser.
To restore access, follow What should I do?.
flutter_map wants to help keep map data available for everyone. One of the largest sources of this data is OpenStreetMap. OpenStreetMap data powers the majority of non-proprietary maps - from actual map tiles/images to navigation data - in existence today. The data itself is free for everyone under the ODbL.
The OpenStreetMap Foundation run OpenStreetMap as a not-for-profit. They also provide a public tile server at https://tile.openstreetmap.org, which is run on donations and volunteering time. This server is used throughout this documentation for code examples, and in our demo app, and is available at the following template URL:
https://tile.openstreetmap.org/{z}/{x}/{y}.pngThe OpenStreetMap public tile server is NOT free to use by everyone
flutter_map can be setup to conform to these requirements - but it may not conform by default.
It is your own responsibility to comply with any appropriate restrictions and requirements set by your chosen tile server/provider. Always read their Terms of Service. Failure to do so may lead to any punishment, at the tile server's discretion.
The OpenStreetMap public tile server is without cost (for users), but, "without cost" ≠ "without restriction" ≠ "open".
What should I do?
Consider switching tile servers
Our docs list multiple alternatives, many of which have free tiers suitable for hobbyists, affordable pricing for commercial usage, and one which is extremely flexible.
Most of these are built off the same OpenStreetMap data, so the actual information contained within the map won't change (although a change in style may not show some data).
If you're a commercial user and want the best balance of flexibility and affordability, consider setting up your own private tile server, based on the OpenStreetMap data! In any case, the OpenStreetMap tile server doesn't offer uptime guarantees, which may be important to your business.
If you're sticking with OpenStreetMap's server, consider preparing a backup.
Read the OpenStreetMap Tile Usage Policy
If you still want to use OpenStreetMap, you must read the policy and comply with its restrictions and requirements. It also contains some background info as to why this is important.
To note two important general terms:
Should any users or patterns of usage nevertheless cause problems to the service, access may still be blocked without prior notice.
This policy may change at any time subject to the needs and constraints of the project. Commercial services, or those that seek donations, should be especially aware that access may be withdrawn at any point: you may no longer be able to serve your paying customers if access is withdrawn.
Also note all the other requirements, which may require you to make adjustments to your project...
Make all necessary adjustments
Check the OSM policy for all the adjustments you might need to make. Here's some common ones:
Enable conforming caching
v8.2.0 introduces automatically enabled Caching! This is designed to meet the caching requirements of the usage policy. Upgrade to v8.2.0 to enable this functionality.
There's also other options to implement caching or offline mapping to meet the requirements, and go beyond the capabilities of the built-in caching.
Add sufficient attribution
The
RichAttributionWidgetorSimpleAttributionWidgetcan both be used to setup attribution which looks great, is unintrusive, and is conforming - provided you add the necessary sources. See Attribution Layer for more info and a simple code snippet you can add to meet the attribution requirement.You can also add attribution in any other way that meets the requirements.
Set a more specific user-agent to identify your client
You should set
TileLayer.userAgentPackageName: see the Recommended Setup for theTileLayer. This is not necessary when running solely on the web, where it is not possible to set a User-Agent manually.
Last updated
Was this helpful?
