47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import {MapContainer,TileLayer} from 'react-leaflet';
|
|
|
|
/*JS module import (vs cdn or style link)*/
|
|
import 'leaflet/dist/leaflet.css'
|
|
import './entities-map.css';
|
|
|
|
import EntitiesMarker from './entities-marker';
|
|
|
|
export default function EntitiesMap({entities}) {
|
|
/*lat and lon of Braunschweig,DE*/
|
|
const position = [52.26594, 10.52673]
|
|
//TODO make this switch available via configuration!
|
|
const hasGtfs = false;
|
|
return (
|
|
<>
|
|
<MapContainer
|
|
center={position}
|
|
zoom={6}
|
|
minZoom={2}
|
|
scrollWheelZoom={true}
|
|
>
|
|
<TileLayer
|
|
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
/>
|
|
{
|
|
entities.map(function(value,key) {
|
|
//console.log(`key: ${key}, tripId: ${value.tripId}`);
|
|
return <EntitiesMarker
|
|
key={value[0]}
|
|
index={value[0]}
|
|
name={value[1]}
|
|
lat={value[2]}
|
|
lon={value[3]}
|
|
/>;
|
|
})
|
|
}
|
|
</MapContainer>
|
|
</>
|
|
);
|
|
}
|
|
EntitiesMap.propTypes = {
|
|
entities: PropTypes.array
|
|
};
|