๐Ÿ“ฆ leonardomso / react-google-static

๐ŸŒ A React wrapper for Google Static Maps API.

โ˜… 46 stars โ‘‚ 4 forks ๐Ÿ‘ 46 watching โš–๏ธ MIT License
googlegoogle-mapsgoogle-maps-apigoogle-static-mapsgoogle-static-maps-apireactstatic-mapsstatic-maps-api
๐Ÿ“ฅ Clone https://github.com/leonardomso/react-google-static.git
HTTPS git clone https://github.com/leonardomso/react-google-static.git
SSH git clone git@github.com:leonardomso/react-google-static.git
CLI gh repo clone leonardomso/react-google-static
Leonardo Maldonado Leonardo Maldonado Merge pull request #361 from leonardomso/dependabot/npm_and_yarn/types/react-18.2.55 826fb42 1 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ example
๐Ÿ“ src
๐Ÿ“ test
๐Ÿ“„ .gitignore
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ tsconfig.json
๐Ÿ“„ yarn.lock
๐Ÿ“„ README.md

๐ŸŒ React Google Static Maps

Actions Status LICENSE MIT npm version

A React component wrapper to use the Google Static Maps API. Don't forget that to use this API you must have a billing account and an Static Maps API key.

This library supports custom markers. To use a custom icon, you should provide a url link, for example: https://img.icons8.com/dusk/64/000000/marker.png.

Installation

npm install react-google-static

yarn add react-google-static

Usage

import React from 'react';
import GoogleStaticMap from 'react-google-static';

const App = () => (
  <div>
    <h1>Google Static Maps API</h1>

    <GoogleStaticMap
      apiKey={API_KEY}
      latitude={32.064171}
      longitude={34.7748068}
      style={{ width: 200, height: 200 }}
      size={{ width: 200, height: 200 }}
      zoom={16}
    />
  </div>
);

export default App;

Usage with Custom Icon

import React from 'react';
import GoogleStaticMap from 'react-google-static';

const App = () => (
  <div>
    <h1>Google Static Maps API</h1>

    <GoogleStaticMap
      apiKey={API_KEY}
      latitude={32.064171}
      longitude={34.7748068}
      style={{ width: 200, height: 200 }}
      size={{ width: 200, height: 200 }}
      zoom={16}
      iconUrl="https://img.icons8.com/dusk/64/000000/marker.png"
    />
  </div>
);

export default App;

Props

Name Type Required
apiKey Boolean true
latitude string | number true
longitude string | number true
size Object true
zoom number true
scale number false
mapFormat 'png' | 'png32' | 'gif' | 'jpg' | 'jpg-baseline' false
mapType 'roadmap' | 'satellite' | 'terrain' | 'hybrid' false
iconUrl string false
style any false