Skip to content

Commit ec9dec1

Browse files
committed
fix for #44 recenter on currentlocation when mission editor is loaded
1 parent 231aa00 commit ec9dec1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/routes/MissionPlanner/components/MissionMap/MissionMap.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import NoFlyZone from 'components/NoFlyZone';
66
import {GOOGLE_MAPS_BOUNDS_TIMEOUT} from 'Const';
77
import styles from './MissionMap.scss';
88

9+
// default center location for mission Planner
910
const mapConfig = {
1011
defaultZoom: 13,
1112
defaultCenter: {
12-
lat: -6.202180076671433,
13-
lng: 106.83877944946289,
13+
lat: 40.01,
14+
lng: -105.27,
1415
},
1516
options: {
1617
clickableIcons: false,
@@ -85,8 +86,10 @@ export class MissionMap extends Component {
8586

8687
handleMapLoad(map) {
8788
this.map = map;
88-
if (map) {
89-
// this.fitMapToBounds(map, this.props.markers);
89+
if (map ) {
90+
if ( this.props.markers.length > 0 ) {
91+
this.fitMapToBounds(map, this.props.markers);
92+
} else {
9093
navigator.geolocation.getCurrentPosition((pos) => {
9194
map.panTo({
9295
lat: pos.coords.latitude,
@@ -98,6 +101,7 @@ export class MissionMap extends Component {
98101
);
99102
}
100103
}
104+
}
101105

102106
render() {
103107
return (

0 commit comments

Comments
 (0)