如何使用反应谷歌地图"view on Google maps"



非常简单,如何在嵌入式GoogleMap中显示链接以在谷歌地图上打开地图。

<GoogleMap
defaultZoom={11}
defaultCenter={{
lat: parseFloat(props.mapCenter.lat),
lng: parseFloat(props.mapCenter.lng)
}}
center={{
lat: parseFloat(props.mapCenter.lat),
lng: parseFloat(props.mapCenter.lng)
}}
defaultOptions={{
controlSize: 20,
mapTypeControl: false,
fullscreenControl: false,
minZoom: 4,
maxZoom: 18,
styles: mapStyles
}}
>

是否有显示链接到";谷歌地图上的视图";在街景模式下有什么时候?

请注意,react-google-maps是为使用maps JavaScript API而创建的库。如果你想在街景模式下使用地图嵌入API,你可以这样做:

import React from "react";
import ReactDOM from "react-dom";
function App() {
return (
<div>
<h1>MAPS!</h1>
<p>Please see map below</p>
<iframe
width="600"
height="450"
style={{ border: 0 }}
loading="lazy"
allowfullscreen
src="https://www.google.com/maps/embed/v1/streetview?key=YOUR_API_KEY&location=46.414382,10.013988&heading=210&pitch=10&fov=35"
/>
</div>
);
}
ReactDOM.render(<App />, document.getElementById("root"));

这是一个示例工作代码。请使用您自己的API密钥使代码工作。

最新更新