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
5a4805b0
Commit
5a4805b0
authored
Dec 25, 2016
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using 'ip-api.com' by specifying default coords in config.
parent
4c7e6b62
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
7 deletions
+19
-7
config.py
examples/geo_alchemy/config.py
+5
-1
form.js
flask_admin/static/admin/js/form.js
+6
-6
lib.html
flask_admin/templates/bootstrap2/admin/lib.html
+4
-0
lib.html
flask_admin/templates/bootstrap3/admin/lib.html
+4
-0
No files found.
examples/geo_alchemy/config.py
View file @
5a4805b0
...
@@ -7,4 +7,8 @@ SQLALCHEMY_ECHO = True
...
@@ -7,4 +7,8 @@ SQLALCHEMY_ECHO = True
# credentials for loading map tiles from mapbox
# credentials for loading map tiles from mapbox
MAPBOX_MAP_ID
=
'...'
MAPBOX_MAP_ID
=
'...'
MAPBOX_ACCESS_TOKEN
=
'...'
MAPBOX_ACCESS_TOKEN
=
'...'
\ No newline at end of file
# when the creating new shapes, use this default map center
DEFAULT_CENTER_LAT
=
-
33.918861
DEFAULT_CENTER_LONG
=
18.423300
flask_admin/static/admin/js/form.js
View file @
5a4805b0
...
@@ -77,6 +77,10 @@
...
@@ -77,6 +77,10 @@
console
.
error
(
"You must set MAPBOX_MAP_ID 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
;
}
}
if
(
!
window
.
DEFAULT_CENTER_LAT
||
!
window
.
DEFAULT_CENTER_LONG
)
{
console
.
error
(
"You must set DEFAULT_CENTER_LAT and DEFAULT_CENTER_LONG in your Flask settings to use the map widget"
);
return
false
;
}
var
geometryType
=
$el
.
data
(
"geometry-type"
)
var
geometryType
=
$el
.
data
(
"geometry-type"
)
if
(
geometryType
)
{
if
(
geometryType
)
{
...
@@ -148,12 +152,8 @@
...
@@ -148,12 +152,8 @@
map
.
fitBounds
(
bounds
);
map
.
fitBounds
(
bounds
);
}
}
}
else
{
}
else
{
// look up user's location by IP address
// use the default map center
$
.
getJSON
(
"//ip-api.com/json/?callback=?"
,
function
(
data
)
{
map
.
setView
([
window
.
DEFAULT_CENTER_LAT
,
window
.
DEFAULT_CENTER_LONG
],
12
);
map
.
setView
([
data
[
"lat"
],
data
[
"lon"
]],
12
);
}).
fail
(
function
()
{
map
.
setView
([
0
,
0
],
1
)
});
}
}
// set up tiles
// set up tiles
...
...
flask_admin/templates/bootstrap2/admin/lib.html
View file @
5a4805b0
...
@@ -234,6 +234,10 @@
...
@@ -234,6 +234,10 @@
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_ACCESS_TOKEN }}"
;
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_ACCESS_TOKEN }}"
;
{
%
endif
%
}
{
%
endif
%
}
{
%
if
config
.
DEFAULT_CENTER_LAT
and
config
.
DEFAULT_CENTER_LONG
%
}
window
.
DEFAULT_CENTER_LAT
=
"{{ config.DEFAULT_CENTER_LAT }}"
;
window
.
DEFAULT_CENTER_LONG
=
"{{ config.DEFAULT_CENTER_LONG }}"
;
{
%
endif
%
}
</script>
</script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js', v='1.0.2') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js', v='1.0.2') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js', v='0.4.6') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js', v='0.4.6') }}"
></script>
...
...
flask_admin/templates/bootstrap3/admin/lib.html
View file @
5a4805b0
...
@@ -225,6 +225,10 @@
...
@@ -225,6 +225,10 @@
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
{
%
if
config
.
MAPBOX_ACCESS_TOKEN
%
}
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_ACCESS_TOKEN }}"
;
window
.
MAPBOX_ACCESS_TOKEN
=
"{{ config.MAPBOX_ACCESS_TOKEN }}"
;
{
%
endif
%
}
{
%
endif
%
}
{
%
if
config
.
DEFAULT_CENTER_LAT
and
config
.
DEFAULT_CENTER_LONG
%
}
window
.
DEFAULT_CENTER_LAT
=
"{{ config.DEFAULT_CENTER_LAT }}"
;
window
.
DEFAULT_CENTER_LONG
=
"{{ config.DEFAULT_CENTER_LONG }}"
;
{
%
endif
%
}
</script>
</script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js', v='1.0.2') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.js', v='1.0.2') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js', v='0.4.6') }}"
></script>
<script
src=
"{{ admin_static.url(filename='vendor/leaflet/leaflet.draw.js', v='0.4.6') }}"
></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