Commit b8de0532 authored by Nitish Rathi's avatar Nitish Rathi

Revert "Give users the option to use mapbox v4"

parent ebf5d597
...@@ -28,11 +28,6 @@ settings:: ...@@ -28,11 +28,6 @@ settings::
app = Flask(__name__) app = Flask(__name__)
app.config['MAPBOX_MAP_ID'] = "example.abc123" app.config['MAPBOX_MAP_ID'] = "example.abc123"
To use the v4 of their API: (Note that while 4 is parameterized here, only v3 and v4 are currently supported.)::
app.config['MAPBOX_ACCESS_TOKEN'] = "pk.def456"
app.config['MAPBOX_API_VERSION'] = 4
.. note:: .. note::
Leaflet supports loading map tiles from any arbitrary map tile provider, but Leaflet supports loading map tiles from any arbitrary map tile provider, but
at the moment, Flask-Admin only supports Mapbox. If you want to use other at the moment, Flask-Admin only supports Mapbox. If you want to use other
......
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
* Process Leaflet (map) widget * Process Leaflet (map) widget
*/ */
function processLeafletWidget($el, name) { function processLeafletWidget($el, name) {
if (!window.MAPBOX_MAP_ID || (window.MAPBOX_API_VERSION === 4 && !window.MAPBOX_ACCESS_TOKEN)) { if (!window.MAPBOX_MAP_ID) {
console.error("You must set MAPBOX_MAP_ID and MAPBOX_ACCESS_TOKEN in your Flask settings to use the map widget"); console.error("You must set MAPBOX_MAP_ID in your Flask settings to use the map widget");
return false; return false;
} }
...@@ -155,11 +155,7 @@ ...@@ -155,11 +155,7 @@
} }
// set up tiles // set up tiles
var mapboxTemplateUrl = 'http://{s}.tiles.mapbox.com/v3/'+MAPBOX_MAP_ID+'/{z}/{x}/{y}.png'; L.tileLayer('http://{s}.tiles.mapbox.com/v3/'+MAPBOX_MAP_ID+'/{z}/{x}/{y}.png', {
if (MAPBOX_API_VERSION === 4) {
mapboxTemplateUrl = 'http://{s}.tiles.mapbox.com/v4/'+MAPBOX_MAP_ID+'/{z}/{x}/{y}.png?access_token='+MAPBOX_ACCESS_TOKEN;
}
L.tileLayer(mapboxTemplateUrl, {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18 maxZoom: 18
}).addTo(map); }).addTo(map);
......
...@@ -187,10 +187,6 @@ ...@@ -187,10 +187,6 @@
{% if config.MAPBOX_MAP_ID %} {% if config.MAPBOX_MAP_ID %}
<script> <script>
window.MAPBOX_MAP_ID = "{{ config.MAPBOX_MAP_ID }}"; window.MAPBOX_MAP_ID = "{{ config.MAPBOX_MAP_ID }}";
{% if config.get(MAPBOX_API_VERSION) == 4 %}
window.MAPBOX_ACCESS_TOKEN = "{{ config.MAPBOX_ACCESS_TOKEN }}";
window.MAPBOX_API_VERSION = "{{ config.MAPBOX_API_VERSION }}";
{% endif %}
</script> </script>
<script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"></script> <script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"></script>
<script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js') }}"></script> <script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js') }}"></script>
......
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
<link href="{{ admin_static.url(filename='vendor/select2/select2.css') }}" rel="stylesheet"> <link href="{{ admin_static.url(filename='vendor/select2/select2.css') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='vendor/select2/select2-bootstrap3.css') }}" rel="stylesheet"> <link href="{{ admin_static.url(filename='vendor/select2/select2-bootstrap3.css') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='vendor/bootstrap-daterangepicker/daterangepicker-bs3.css') }}" rel="stylesheet"> <link href="{{ admin_static.url(filename='vendor/bootstrap-daterangepicker/daterangepicker-bs3.css') }}" rel="stylesheet">
{% if config.MAPBOX_MAP_ID and config.MAPBOX_ACCESS_TOKEN %} {% if config.MAPBOX_MAP_ID %}
<link href="{{ admin_static.url(filename='vendor/leaflet/leaflet.css') }}" rel="stylesheet"> <link href="{{ admin_static.url(filename='vendor/leaflet/leaflet.css') }}" rel="stylesheet">
<link href="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.css') }}" rel="stylesheet"> <link href="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.css') }}" rel="stylesheet">
{% endif %} {% endif %}
...@@ -179,13 +179,9 @@ ...@@ -179,13 +179,9 @@
{% endmacro %} {% endmacro %}
{% macro form_js() %} {% macro form_js() %}
{% if config.MAPBOX_MAP_ID and config.MAPBOX_ACCESS_TOKEN %} {% if config.MAPBOX_MAP_ID %}
<script> <script>
window.MAPBOX_MAP_ID = "{{ config.MAPBOX_MAP_ID }}"; window.MAPBOX_MAP_ID = "{{ config.MAPBOX_MAP_ID }}";
{% if config.get('MAPBOX_API_VERSION') == 4 %}
window.MAPBOX_ACCESS_TOKEN = "{{ config.MAPBOX_ACCESS_TOKEN }}";
window.MAPBOX_API_VERSION = "{{ config.MAPBOX_API_VERSION }}";
{% endif %}
</script> </script>
<script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"></script> <script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"></script>
<script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js') }}"></script> <script src="{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js') }}"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment