-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmap.js
executable file
·63 lines (51 loc) · 1.84 KB
/
map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// OpenLayers 3 - Test with mapserver for B-CGMS - Julien Minet - July 2016.
// Definition of OpenLayers controls
var scaleLine = new ol.control.ScaleLine()
// Map creation
var olmap = new ol.Map({
target: document.getElementById('map'), // instead of "target: 'map' " because of the cursor pointer
view: new ol.View({
center: ol.proj.transform([3.65, 50.5], 'EPSG:4326', 'EPSG:3857'), // set the center of the map. By default, the map projection is EPSG:3857
zoom: 8
}),
controls: ol.control.defaults({scaleLine: false}).extend([scaleLine]), // Add the scaleline control
});
// Add default layers
var osmLayer = new ol.layer.Tile({
source: new ol.source.OSM()
});
olmap.addLayer(osmLayer);
// Add specific classes to OpenLayers elements: hide these controls for mobile view using Bootstrap classes
$('.ol-scale-line').addClass('hidden-xs')
$('.ol-attribution').addClass('hidden-xs')
// Hide/show panel function for desktop view. The panel is shown by default.
var showPanel = true;
var collapsePanel = function(){
if(showPanel === true){
$('div#panel').css('width','35px');
$('div#panelContent').css('opacity','0' );
$('div#collapseBtn button').text('>');
showPanel =! showPanel;
}
else{
$('div#panel').css('width','300px');
$('div#panelContent').css('opacity','1');
$('div#collapseBtn button').text('<');
showPanel =! showPanel;
}
}
// Hide/show panel function for mobile view. The panel is not shown by default.
var showPanelXs = false;
var collapsePanelXs = function(){
if(showPanelXs === true){
$('div#panel').css('width','0px');
$('div#panelContent').css('opacity','0' );
showPanelXs =! showPanelXs;
}
else{
$('div#panel').css('width','calc(100% - 45px)');
$('div#panelContent').css('opacity','1');
$('div#navbar').removeClass('in')
showPanelXs =! showPanelXs;
}
}