最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How I can make a static map with google-map-react in react? - Stack Overflow

programmeradmin1浏览0评论

I have this :

 <GoogleMapReact
      bootstrapURLKeys={{ key: 'key' }}
      defaultCenter={center}
      defaultZoom={zoom}
>
  <TacoMarker
   link={shop.id}
   lat={latitude}
   lng={longitude}
  />

 </GoogleMapReact>

What props can I pass you? Would it be like a scrollEnabled = {false}?

I have this :

 <GoogleMapReact
      bootstrapURLKeys={{ key: 'key' }}
      defaultCenter={center}
      defaultZoom={zoom}
>
  <TacoMarker
   link={shop.id}
   lat={latitude}
   lng={longitude}
  />

 </GoogleMapReact>

What props can I pass you? Would it be like a scrollEnabled = {false}?

Share Improve this question edited Mar 31, 2021 at 3:53 user140327 asked Mar 30, 2021 at 18:25 lautarolautaro 531 silver badge6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

google-map-react is written to use Maps JavaScript API. Please note that Maps JavaScript API is different from Maps Static API. If you would like to show a static map in your react code, you can just directly put the Maps Static API URL in the src parameter of your <img/> tag.

Here's a sample code snippet:

import React from "react";
import ReactDOM from "react-dom";

function App() {
  return (
    <div>
      <h1>Static Maps Sample</h1>
      <img src="https://maps.googleapis./maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=YOUR_API_KEY"/>   
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById("root"));
发布评论

评论列表(0)

  1. 暂无评论