tracktracker/src/front/map/index.js

32 lines
831 B
JavaScript
Raw Normal View History

import "ol/ol.css";
import { Map, View } from "ol";
import * as proj from "ol/proj";
import { getLayers as getTilesLayers } from "./tiles";
import { getLayers as getNetworkLayers } from "./network";
import { setupCoursesAnimation } from "./courses";
2020-07-23 18:49:01 +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,
constrainResolution: true
2020-07-23 15:29:35 +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,
layers: [...tilesLayers, ...networkLayers],
view
2020-07-23 18:49:01 +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;
};