diff options
Diffstat (limited to 'src/client/views/collections/CollectionMapView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionMapView.tsx | 23 | 
1 files changed, 12 insertions, 11 deletions
| diff --git a/src/client/views/collections/CollectionMapView.tsx b/src/client/views/collections/CollectionMapView.tsx index c80555a2e..971224482 100644 --- a/src/client/views/collections/CollectionMapView.tsx +++ b/src/client/views/collections/CollectionMapView.tsx @@ -1,4 +1,4 @@ -import { GoogleApiWrapper, Map as GeoMap, MapProps, Marker } from "google-maps-react"; +import { GoogleApiWrapper, Map as GeoMap, IMapProps, Marker } from "google-maps-react";  import { observer } from "mobx-react";  import { Doc, Opt, DocListCast, FieldResult, Field } from "../../../new_fields/Doc";  import { documentSchema } from "../../../new_fields/documentSchemas"; @@ -42,7 +42,7 @@ const query = async (data: string | google.maps.LatLngLiteral) => {  };  @observer -class CollectionMapView extends CollectionSubView<MapSchema, Partial<MapProps> & { google: any }>(MapSchema) { +class CollectionMapView extends CollectionSubView<MapSchema, Partial<IMapProps> & { google: any }>(MapSchema) {      private _cancelAddrReq = new Map<string, boolean>();      private _cancelLocReq = new Map<string, boolean>(); @@ -208,10 +208,8 @@ class CollectionMapView extends CollectionSubView<MapSchema, Partial<MapProps> &          const { Document, fieldKey, active, google } = this.props;          let center = this.getLocation(Document, `${fieldKey}-mapCenter`, false);          if (center === undefined) { -            center = childLayoutPairs.map(({ layout }) => this.getLocation(layout, Doc.LayoutFieldKey(layout), false)).find(layout => layout); -            if (center === undefined) { -                center = defaultLocation; -            } +            const childLocations = childLayoutPairs.map(({ layout }) => this.getLocation(layout, Doc.LayoutFieldKey(layout), false)); +            center = childLocations.find(location => location) || defaultLocation;          }          return <div className="collectionMapView" ref={this.createDashEventsTarget}>              <div className={"collectionMapView-contents"} @@ -223,19 +221,22 @@ class CollectionMapView extends CollectionSubView<MapSchema, Partial<MapProps> &                      zoom={center.zoom || 10}                      initialCenter={center}                      center={center} -                    onIdle={(_props?: MapProps, map?: google.maps.Map) => { +                    onIdle={(_props?: IMapProps, map?: google.maps.Map) => {                          if (this.layoutDoc.lockedTransform) { -                            map?.setZoom(center?.zoom || 10); // reset zoom (probably can tell the map to disallow zooming somehow) +                            // reset zoom (ideally, we could probably can tell the map to disallow zooming somehow instead) +                            map?.setZoom(center?.zoom || 10); +                            map?.setCenter({ lat: center?.lat!, lng: center?.lng! });                          } else {                              const zoom = map?.getZoom(); -                            center?.zoom !== zoom && undoBatch(action(() => { +                            (center?.zoom !== zoom) && undoBatch(action(() => {                                  Document[`${fieldKey}-mapCenter-zoom`] = zoom;                              }))();                          }                      }} -                    onDragend={(_props?: MapProps, map?: google.maps.Map) => { +                    onDragend={(_props?: IMapProps, map?: google.maps.Map) => {                          if (this.layoutDoc.lockedTransform) { -                            map?.setCenter({ lat: center?.lat!, lng: center?.lng! }); // reset the drag (probably can tell the map to disallow dragging somehow) +                            // reset the drag (ideally, we could probably can tell the map to disallow dragging somehow instead) +                            map?.setCenter({ lat: center?.lat!, lng: center?.lng! });                          } else {                              undoBatch(action(({ lat, lng }) => {                                  Document[`${fieldKey}-mapCenter-lat`] = lat(); | 
