2021-05-11 19:39:24 +00:00
|
|
|
import "ol/ol.css";
|
|
|
|
|
|
|
|
import { Map, View } from "ol";
|
|
|
|
import * as proj from "ol/proj";
|
2021-05-24 20:59:56 +00:00
|
|
|
import { getLayers as getTilesLayers } from "./tiles";
|
|
|
|
import { getLayers as getNetworkLayers } from "./network";
|
|
|
|
import { setupCoursesAnimation } from "./courses";
|
2020-07-23 18:49:01 +00:00
|
|
|
|
2021-05-11 19:39:24 +00:00
|
|
|
export const create = (target, coursesSimulation, onClick) => {
|
2020-07-23 18:49:01 +00:00
|
|
|
const view = new View({
|
|
|
|
center: proj.fromLonLat([3.88, 43.605]),
|
2020-07-23 21:09:05 +00:00
|
|
|
zoom: 14,
|
2020-07-23 18:49:01 +00:00
|
|
|
maxZoom: 22,
|
2020-07-25 16:05:43 +00:00
|
|
|
constrainResolution: true
|
2020-07-23 15:29:35 +00:00
|
|
|
});
|
|
|
|
|
2021-05-24 20:59:56 +00:00
|
|
|
const tilesLayers = getTilesLayers();
|
|
|
|
const networkLayers = getNetworkLayers();
|
|
|
|
const stopsLayer = networkLayers[2];
|
|
|
|
|
2020-07-17 17:17:06 +00:00
|
|
|
const map = new Map({
|
|
|
|
target,
|
2021-05-24 20:59:56 +00:00
|
|
|
layers: [...tilesLayers, ...networkLayers],
|
2020-07-25 16:05:43 +00:00
|
|
|
view
|
2020-07-23 18:49:01 +00:00
|
|
|
});
|
|
|
|
|
2021-05-24 20:59:56 +00:00
|
|
|
setupCoursesAnimation(map, coursesSimulation, stopsLayer, onClick);
|
2020-07-23 18:49:01 +00:00
|
|
|
map.render();
|
2020-07-23 23:32:39 +00:00
|
|
|
|
2020-07-17 17:17:06 +00:00
|
|
|
return map;
|
|
|
|
};
|