synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
79 lines (78 loc) • 2.43 kB
JavaScript
import { jsx as e } from "react/jsx-runtime";
import { getGoogleMapsApiKey as h, getSynapseTeamGeoData as w, getAllSynapseUserGeoData as S } from "../../synapse-client/SynapseClient.js";
import "@sage-bionetworks/synapse-client/generated/models/ErrorResponseCode";
import "@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse";
import "@sage-bionetworks/synapse-client/util/SynapseClientError";
import "@sage-bionetworks/synapse-types";
import "../../utils/functions/EntityTypeUtils.js";
import "../../utils/SynapseConstants.js";
import "lodash-es";
import "@sage-bionetworks/synapse-client/util/synapseClientFetch";
import { LoadScript as C, GoogleMap as D } from "@react-google-maps/api";
import { useQuery as s } from "@tanstack/react-query";
import { useState as G, useCallback as L, useMemo as K } from "react";
import { SynapseSpinner as m } from "../LoadingScreen/LoadingScreen.js";
import { SynapseUserMarker as M } from "./SynapseUserMarker.js";
function v(u) {
const { teamId: r, apiKeyOverride: a } = u, { data: n } = s({
queryKey: ["googleMapsApiKey"],
queryFn: h,
throwOnError: !0
}), [c, i] = G(
null
), { data: t, isLoading: f } = s({
queryKey: ["synapseGeoData", r],
queryFn: () => r ? w(r) : S(),
throwOnError: !0
}), g = L(
function(d) {
if (t) {
const p = new google.maps.LatLngBounds();
t.forEach((l) => {
p.extend({ lat: l.latLng[0], lng: l.latLng[1] });
}), d.fitBounds(p);
}
},
[t]
), y = K(
() => ({
zoom: 1,
scrollwheel: !0,
mapTypeControl: !1,
streetViewControl: !1,
draggable: !0,
maxZoom: 12,
controlSize: 22
}),
[]
);
return !(a || n) || f ? /* @__PURE__ */ e(m, {}) : /* @__PURE__ */ e(
C,
{
googleMapsApiKey: a || n,
loadingElement: /* @__PURE__ */ e(m, {}),
children: /* @__PURE__ */ e(
D,
{
mapContainerStyle: { height: "100%", width: "100%" },
onLoad: g,
options: y,
children: t.map((o) => /* @__PURE__ */ e(
M,
{
geoData: o,
onClick: () => i(o),
onInfoWindowCloseClick: () => i(null),
showInfoWindow: o === c
},
o.location
))
}
)
}
);
}
export {
v as default
};
//# sourceMappingURL=GoogleMap.js.map