Show error when mapbox token doesn't exist
Signed-off-by: Alfredos-Panagiotis Damkalis <fredy@fredy.gr>merge-requests/797/head
parent
01e3493f9f
commit
f8920087ba
|
@ -32,50 +32,56 @@ $(document).ready(function() {
|
|||
$('#map-station').html('Map can\'t be rendered:<br/> Your browser does not support MapboxGL (WebGL required).');
|
||||
} else {
|
||||
var mapboxtoken = $('div#map-station').data('mapboxtoken');
|
||||
mapboxgl.accessToken = mapboxtoken;
|
||||
var map = new mapboxgl.Map({
|
||||
container: 'map-station',
|
||||
style: 'mapbox://styles/pierros/cj8kftshl4zll2slbelhkndwo',
|
||||
zoom: 5,
|
||||
minZoom: 2,
|
||||
center: [parseFloat(station_info.lng),parseFloat(station_info.lat)]
|
||||
});
|
||||
map.addControl(new mapboxgl.NavigationControl());
|
||||
map.on('load', function () {
|
||||
map.loadImage('/static/img/pin.png', function(error, image) {
|
||||
map.addImage('pin', image);
|
||||
var map_points = {
|
||||
'id': 'points',
|
||||
'type': 'symbol',
|
||||
'source': {
|
||||
'type': 'geojson',
|
||||
'data': {
|
||||
'type': 'FeatureCollection',
|
||||
'features': [{
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [
|
||||
parseFloat(station_info.lng),
|
||||
parseFloat(station_info.lat)]
|
||||
},
|
||||
'properties': {
|
||||
'description': '<a href="/stations/' + station_info.id + '">' + station_info.id + ' - ' + station_info.name + '</a>',
|
||||
'icon': 'circle'
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
'layout': {
|
||||
'icon-image': 'pin',
|
||||
'icon-size': 0.4,
|
||||
'icon-allow-overlap': true
|
||||
}
|
||||
};
|
||||
map.addLayer(map_points);
|
||||
if (!mapboxtoken) {
|
||||
$('#map-station').addClass('error');
|
||||
$('#map-station').addClass('alert-error');
|
||||
$('#map-station').html('Map can\'t be rendered:<br/> Mapbox Token is not available.');
|
||||
} else {
|
||||
mapboxgl.accessToken = mapboxtoken;
|
||||
var map = new mapboxgl.Map({
|
||||
container: 'map-station',
|
||||
style: 'mapbox://styles/pierros/cj8kftshl4zll2slbelhkndwo',
|
||||
zoom: 5,
|
||||
minZoom: 2,
|
||||
center: [parseFloat(station_info.lng),parseFloat(station_info.lat)]
|
||||
});
|
||||
map.repaint = true;
|
||||
});
|
||||
map.addControl(new mapboxgl.NavigationControl());
|
||||
map.on('load', function () {
|
||||
map.loadImage('/static/img/pin.png', function(error, image) {
|
||||
map.addImage('pin', image);
|
||||
var map_points = {
|
||||
'id': 'points',
|
||||
'type': 'symbol',
|
||||
'source': {
|
||||
'type': 'geojson',
|
||||
'data': {
|
||||
'type': 'FeatureCollection',
|
||||
'features': [{
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
'type': 'Point',
|
||||
'coordinates': [
|
||||
parseFloat(station_info.lng),
|
||||
parseFloat(station_info.lat)]
|
||||
},
|
||||
'properties': {
|
||||
'description': '<a href="/stations/' + station_info.id + '">' + station_info.id + ' - ' + station_info.name + '</a>',
|
||||
'icon': 'circle'
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
'layout': {
|
||||
'icon-image': 'pin',
|
||||
'icon-size': 0.4,
|
||||
'icon-allow-overlap': true
|
||||
}
|
||||
};
|
||||
map.addLayer(map_points);
|
||||
});
|
||||
map.repaint = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Slider filters for pass predictions
|
||||
|
|
Loading…
Reference in New Issue