diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-03-18 23:53:48 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-03-18 23:53:48 -0700 |
commit | 889bc0667e21d1154ac2749842696aac0812ef8c (patch) | |
tree | 320b976b61bb16c72bebb4426f88584d5056392a | |
parent | 10f244d54f795bbeebc280248e26f9c078a639fd (diff) | |
download | trackermap-web-889bc0667e21d1154ac2749842696aac0812ef8c.tar.gz trackermap-web-889bc0667e21d1154ac2749842696aac0812ef8c.tar.bz2 trackermap-web-889bc0667e21d1154ac2749842696aac0812ef8c.zip |
Change map initialization
-rw-r--r-- | modern/src/MainMap.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index 1bda9660..8b363c9b 100644 --- a/modern/src/MainMap.js +++ b/modern/src/MainMap.js @@ -1,6 +1,8 @@ import 'ol/ol.css'; import React, { Component } from 'react'; import { connect } from 'react-redux'; +import { Map, View } from 'ol'; +import { fromLonLat } from 'ol/proj'; import olms from 'ol-mapbox-style'; const mapStateToProps = state => ({ @@ -9,7 +11,15 @@ const mapStateToProps = state => ({ class MainMap extends Component { componentDidMount() { - olms(this.el, 'https://cdn.traccar.com/map/basic.json'); + this.map = new Map({ + target: this.el, + view: new View({ + constrainResolution: true, + center: fromLonLat([14.5, 46.05]), + zoom: 3 + }) + }); + olms(this.map, 'https://cdn.traccar.com/map/basic.json'); } render() { |