Fixed initial zoom and center on maps

This commit is contained in:
Alejandro Celaya
2019-03-03 11:47:19 +01:00
parent e9e808d339
commit 6291af2865
2 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import React from 'react';
import { Modal, ModalBody } from 'reactstrap';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
import { map, prop } from 'ramda';
import * as PropTypes from 'prop-types';
import './MapModal.scss';
@@ -25,6 +26,8 @@ const OpenStreetMapTile = () => (
/>
);
const calculateMapBounds = map(prop('latLong'));
const MapModal = ({ toggle, isOpen, title, locations }) => (
<Modal toggle={toggle} isOpen={isOpen} className="map-modal__modal" contentClassName="map-modal__modal-content">
<ModalBody className="map-modal__modal-body">
@@ -32,7 +35,7 @@ const MapModal = ({ toggle, isOpen, title, locations }) => (
{title}
<button type="button" className="close" onClick={toggle}>&times;</button>
</h3>
<Map center={[ 0, 0 ]} zoom="3">
<Map bounds={calculateMapBounds(locations)}>
<OpenStreetMapTile />
{locations.map(({ cityName, latLong, count }, index) => (
<Marker key={index} position={latLong}>