Я создал проект React для Code Sandbox на основе примера React Google Maps GroundOverlay
(https://tomchentw.github.io/react-google-maps/#groundoverlay) здесь: https://codesandbox.io/s/zkq1pv58zp. Вот index.js
:
import React from "react";
import ReactDOM from "react-dom";
const { compose } = require("recompose");
const {
withScriptjs,
withGoogleMap,
GoogleMap,
GroundOverlay,
} = require("react-google-maps");
const MapWithGroundOverlay = compose(
withScriptjs,
withGoogleMap
)(props =>
<GoogleMap
defaultZoom={12}
defaultCenter={{lat: 40.740, lng: -74.18}}
>
<GroundOverlay
defaultUrl="https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg"
defaultBounds={new google.maps.LatLngBounds(
new google.maps.LatLng(40.712216, -74.22655),
new google.maps.LatLng(40.773941, -74.12544)
)}
defaultOpacity={.5}
/>
</GoogleMap>
);
import "./styles.css";
function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<MapWithGroundOverlay
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyBimnrhiugaGSNN8WnsjpzMNJcrH_T60GI&v=3.exp&libraries=geometry,drawing,places"
loadingElement={<div style={{ height: `100%` }} />}
containerElement={<div style={{ height: `400px` }} />}
mapElement={<div style={{ height: `100%` }} />}
/>
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Однако, когда я нажимаю кнопку «скачать», ничего не происходит. Мне кажется, что похожая проблема описана на https://github.com/CompuIves/codesandbox-client/issues/658, связанная с тем, что у приложения нет каталога src
, но я создал проект из шаблона React, и у него есть каталог src
.
Есть идеи, почему проект не скачивается?
(Между прочим, я пытаюсь решить проблему В React Google Maps получение "google" не определено ", даже если компонент обернут с помощью сценария jj? , в котором я получаю "google" is not defined
в моем локальном приложении; каким-то образом приложение в Code Sandbox работает, но я не понимаю, почему локальное не работает).