From 889bc0667e21d1154ac2749842696aac0812ef8c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 18 Mar 2020 23:53:48 -0700 Subject: Change map initialization --- modern/src/MainMap.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modern') diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js index 1bda966..8b363c9 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() { -- cgit v1.2.3