Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
000eb4e0
Commit
000eb4e0
authored
Apr 28, 2015
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #862 from nitishr/revert-860-ks-mapbox-v4
Revert 860 ks mapbox v4
parents
ebf5d597
55c690d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
17 deletions
+15
-17
db_geoa.rst
doc/db_geoa.rst
+1
-2
form-1.0.0.js
flask_admin/static/admin/js/form-1.0.0.js
+8
-7
lib.html
flask_admin/templates/bootstrap2/admin/lib.html
+2
-3
lib.html
flask_admin/templates/bootstrap3/admin/lib.html
+4
-5
No files found.
doc/db_geoa.rst
View file @
000eb4e0
...
...
@@ -28,10 +28,9 @@ settings::
app = Flask(__name__)
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.)
::
To use the v4 of their API
(the default is v3):
::
app.config['MAPBOX_ACCESS_TOKEN'] = "pk.def456"
app.config['MAPBOX_API_VERSION'] = 4
.. note::
Leaflet supports loading map tiles from any arbitrary map tile provider, but
...
...
flask_admin/static/admin/js/form-1.0.0.js
View file @
000eb4e0
...
...
@@ -73,11 +73,15 @@
* Process Leaflet (map) widget
*/
function
processLeafletWidget
(
$el
,
name
)
{
if
(
!
window
.
MAPBOX_MAP_ID
||
(
window
.
MAPBOX_API_VERSION
===
4
&&
!
window
.
MAPBOX_ACCESS_TOKEN
)
)
{
console
.
error
(
"You must set MAPBOX_MAP_ID
and MAPBOX_ACCESS_TOKEN
in your Flask settings to use the map widget"
);
if
(
!
window
.
MAPBOX_MAP_ID
)
{
console
.
error
(
"You must set MAPBOX_MAP_ID in your Flask settings to use the map widget"
);
return
false
;
}
if
(
!
window
.
MAPBOX_ACCESS_TOKEN
)
{
console
.
warn
(
"You must set MAPBOX_ACCESS_TOKEN in your Flask settings to use the map widget with mapbox v4 API"
);
}
var
geometryType
=
$el
.
data
(
"geometry-type"
)
if
(
geometryType
)
{
geometryType
=
geometryType
.
toUpperCase
();
...
...
@@ -155,11 +159,8 @@
}
// set up tiles
var
mapboxTemplateUrl
=
'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
,
{
mapboxVersion
=
window
.
MAPBOX_ACCESS_TOKEN
?
4
:
3
L
.
tileLayer
(
'http://{s}.tiles.mapbox.com/v'
+
mapboxVersion
+
'/'
+
MAPBOX_MAP_ID
+
'/{z}/{x}/{y}.png?access_token='
+
window
.
MAPBOX_ACCESS_TOKEN
,
{
attribution
:
'Map data © <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
}).
addTo
(
map
);
...
...
flask_admin/templates/bootstrap2/admin/lib.html
View file @
000eb4e0
...
...
@@ -187,9 +187,8 @@
{% if config.MAPBOX_MAP_ID %}
<script>
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 }}"
;
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_MAP_ID }}"
;
{
%
endif
%
}
</script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"
></script>
...
...
flask_admin/templates/bootstrap3/admin/lib.html
View file @
000eb4e0
...
...
@@ -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-bootstrap3.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.draw.css') }}"
rel=
"stylesheet"
>
{% endif %}
...
...
@@ -179,12 +179,11 @@
{% endmacro %}
{% macro form_js() %}
{% if config.MAPBOX_MAP_ID
and config.MAPBOX_ACCESS_TOKEN
%}
{% if config.MAPBOX_MAP_ID %}
<script>
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 }}"
;
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_MAP_ID }}"
;
{
%
endif
%
}
</script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js') }}"
></script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment