Code Monkey home page Code Monkey logo

react-google-map-wrapper's Introduction

react-google-map-wrapper is a React component library for rendering Google Maps.

You can see an example here.

import { Suspense } from 'react';
import { GoogleMap, GoogleMapApiLoader, Marker } from 'react-google-map-wrapper';

function Map() {
  return (
    <GoogleMap className='h-[400px]' zoom={17} center={{ lat: 37.5709413, lng: 126.977787 }}>
      <Marker lat={37.5709413} lng={126.977787} />
    </GoogleMap>
  );
}

function App() {
  return (
    <Suspense fallback={<Fallback />}>
      {/* Load the google map api */}
      <GoogleMapApiLoader apiKey='YOUR_API_KEY' suspense>
        <Map />
      </GoogleMapApiLoader>
    </Suspense>
  );
}

Installation

npm install react-google-map-wrapper # or yarn add react-google-map-wrapper or pnpm add react-google-map-wrapper

Documentation

You can find the documentation on the website.

Check out the Getting Started page for a quick overview.

License

react-google-map-wrapper is MIT licensed.

react-google-map-wrapper's People

Contributors

pyjun01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-google-map-wrapper's Issues

Recenter not working

The center param seems to only be working as an initial value, when the value changes the map does not recenter, I have verified the field has been updating.

const mapCenter = useMemo(
    () => ({
      lat: ownItinerary?.destinations[0]?.lat || 0,
      lng: ownItinerary?.destinations[0]?.lon || 0,
    }),
    [ownItinerary]
  );

<GoogleMap
  mapOptions={{
    mapId: process.env.NEXT_PUBLIC_GOOGLE_MAPS_MAP_ID,
    disableDefaultUI: true,
    clickableIcons: true,
  }}
  style={{ width: "100%", height: "100%" }}
  center={mapCenter}
  zoom={5}
  onLoad={() => console.log("Map Component Loaded...")}
>
</GoogleMap>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.