Optional 'zoom' parameter added to the map page to override Google Maps auto-zoom (needed if the page is embedded in an iframe)
This commit is contained in:
parent
ab02d7e79c
commit
d89b03a697
3 changed files with 22 additions and 2 deletions
|
@ -147,6 +147,13 @@ class HttpBackend(Backend):
|
||||||
@app.route('/map', methods=['GET'])
|
@app.route('/map', methods=['GET'])
|
||||||
def map():
|
def map():
|
||||||
"""
|
"""
|
||||||
|
Query parameters:
|
||||||
|
start -- Map timeline start timestamp
|
||||||
|
end -- Map timeline end timestamp
|
||||||
|
zoom -- Between 1-20. Set it if you want to override the
|
||||||
|
Google's API auto-zoom. You may have to set it if you are
|
||||||
|
trying to embed the map into an iframe
|
||||||
|
|
||||||
Supported values for `start` and `end`:
|
Supported values for `start` and `end`:
|
||||||
- now
|
- now
|
||||||
- yesterday
|
- yesterday
|
||||||
|
@ -158,6 +165,7 @@ class HttpBackend(Backend):
|
||||||
|
|
||||||
Default: start=yesterday, end=now
|
Default: start=yesterday, end=now
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_time(time_string):
|
def parse_time(time_string):
|
||||||
if not time_string:
|
if not time_string:
|
||||||
return None
|
return None
|
||||||
|
@ -200,9 +208,11 @@ class HttpBackend(Backend):
|
||||||
|
|
||||||
start = parse_time(http_request.args.get('start', default='yesterday'))
|
start = parse_time(http_request.args.get('start', default='yesterday'))
|
||||||
end = parse_time(http_request.args.get('end', default='now'))
|
end = parse_time(http_request.args.get('end', default='now'))
|
||||||
|
zoom = http_request.args.get('zoom', default=None)
|
||||||
|
|
||||||
return render_template('map.html', config=self.maps,
|
return render_template('map.html', config=self.maps,
|
||||||
utils=HttpUtils, start=start, end=end,
|
utils=HttpUtils, start=start, end=end,
|
||||||
token=self.token, api_key=api_key,
|
zoom=zoom, token=self.token, api_key=api_key,
|
||||||
websocket_port=self.websocket_port)
|
websocket_port=self.websocket_port)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -48,7 +48,11 @@ function initMapFromGeopoints(points) {
|
||||||
// Now fit the map to the newly inclusive bounds
|
// Now fit the map to the newly inclusive bounds
|
||||||
map.fitBounds(bounds);
|
map.fitBounds(bounds);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
map.setZoom(getBoundsZoomLevel(bounds, $map.children().width(), $map.children().height()));
|
if (window.zoom) {
|
||||||
|
map.setZoom(window.zoom);
|
||||||
|
} else {
|
||||||
|
map.setZoom(getBoundsZoomLevel(bounds, $map.children().width(), $map.children().height()));
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
google.maps.event.removeListener(listener);
|
google.maps.event.removeListener(listener);
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
window.map_start = "{{ start }}";
|
window.map_start = "{{ start }}";
|
||||||
window.map_end = "{{ end }}";
|
window.map_end = "{{ end }}";
|
||||||
|
|
||||||
|
{% if zoom %}
|
||||||
|
window.zoom = {{ zoom }};
|
||||||
|
{% else %}
|
||||||
|
window.zoom = undefined;
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if token %}
|
{% if token %}
|
||||||
window.token = '{{ token }}'
|
window.token = '{{ token }}'
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Loading…
Reference in a new issue