|
@@ -5,11 +5,10 @@ import ReactMapboxGl, {
|
|
|
ZoomControl,
|
|
|
ScaleControl,
|
|
|
RotationControl,
|
|
|
- Marker
|
|
|
} from 'react-mapbox-gl';
|
|
|
import mapboxToken from './config/mapboxToken.js';
|
|
|
import {calcDistance} from './helpers/distance';
|
|
|
-import {longitude, latitude, mapWidth, mapHeight, markerIcon} from "./config/variables";
|
|
|
+import {longitude, latitude, mapWidth, mapHeight} from "./config/variables";
|
|
|
|
|
|
const Map = ReactMapboxGl({ accessToken: mapboxToken });
|
|
|
|
|
@@ -19,7 +18,8 @@ export default class Mapbox extends React.Component{
|
|
|
longitude: longitude,
|
|
|
zoom: [15],
|
|
|
path: [[longitude, latitude]],
|
|
|
- distance: 0
|
|
|
+ distance: 0,
|
|
|
+ center: [longitude, latitude]
|
|
|
}
|
|
|
|
|
|
addMarker = (event, click) => {
|
|
@@ -61,11 +61,10 @@ export default class Mapbox extends React.Component{
|
|
|
height: mapHeight,
|
|
|
width: mapWidth
|
|
|
}}
|
|
|
- center={position}
|
|
|
+ center={this.state.center}
|
|
|
zoom={this.state.zoom}
|
|
|
onClick={(e, c) => this.addMarker(e, c)}
|
|
|
>
|
|
|
-
|
|
|
<Layer type="symbol" id="marker" layout={{"icon-image": "marker-15" }}>
|
|
|
{this.state.path.map((pos, idx) =>
|
|
|
<Feature
|
|
@@ -73,15 +72,6 @@ export default class Mapbox extends React.Component{
|
|
|
key={idx} draggable={true}
|
|
|
onDragEnd={(e) => this.updateMarker(idx, e)}
|
|
|
/>
|
|
|
-// <Marker
|
|
|
-// coordinates={pos}
|
|
|
-// anchor="bottom"
|
|
|
-// key={idx}
|
|
|
-// >
|
|
|
-// <svg height={20} viewBox="0 0 24 24" style={{fill: "#343a40"}}>
|
|
|
-// <path d={markerIcon} />
|
|
|
-// </svg>
|
|
|
-// </Marker>
|
|
|
)}
|
|
|
</Layer>
|
|
|
<ZoomControl position={"top-right"}/>
|