All Projects β†’ cedricdelpoux β†’ react-google-map

cedricdelpoux / react-google-map

Licence: MIT license
React component to render a map with markers from Google Maps API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-google-map

orange3-geo
🍊 🌍 Orange add-on for dealing with geography and geo-location
Stars: ✭ 22 (-12%)
Mutual labels:  maps
Weltenschaft
Open-Source terrain generator πŸ—ΊοΈ
Stars: ✭ 41 (+64%)
Mutual labels:  maps
cim-spec
This repository hosts the specification for the Cartographic Information Model
Stars: ✭ 45 (+80%)
Mutual labels:  maps
Trilateration
Trilateration system using 3 latitude and longitude points, and 3 radius distances in PHP, C#, Java and Javascript
Stars: ✭ 22 (-12%)
Mutual labels:  maps
activeadmin-latlng
Active Admin plugin for setting up latitude and longitude
Stars: ✭ 34 (+36%)
Mutual labels:  maps
s60-maps
Yet another maps for Symbian OS
Stars: ✭ 27 (+8%)
Mutual labels:  maps
Euclid
Great-circle mathematics helper library for platforms using Swift -
Stars: ✭ 46 (+84%)
Mutual labels:  maps
elm-mapbox
MapboxGL bindings for Elm
Stars: ✭ 55 (+120%)
Mutual labels:  maps
react-native-open-map
Choose the application that will open the map
Stars: ✭ 27 (+8%)
Mutual labels:  maps
osm-geojson
πŸ”° Get GeoJSON of a OpenStreetMap's relation from the API.
Stars: ✭ 42 (+68%)
Mutual labels:  maps
aic-mobile-ios
Art Institute of Chicago Official Mobile App
Stars: ✭ 29 (+16%)
Mutual labels:  maps
PowerCollections
Powerfull Collections, Sets, Lists and Maps.
Stars: ✭ 15 (-40%)
Mutual labels:  maps
ScoutAR
Augmented reality app displays nearby restaurant information in a live camera and map view.
Stars: ✭ 28 (+12%)
Mutual labels:  maps
leaflet-draw-toolbar
Leaflet.toolbar for Leaflet.draw. Example: https://justinmanley.github.io/leaflet-draw-toolbar/examples/popup.html.
Stars: ✭ 55 (+120%)
Mutual labels:  maps
organicmaps
πŸƒ Organic Maps is a free Android & iOS offline maps app for travelers, tourists, hikers, and cyclists. It uses crowd-sourced OpenStreetMap data and is developed with love by MapsWithMe (MapsMe) founders and our community. No ads, no tracking, no data collection, no crapware. Your donations and positive reviews motivate and inspire our small team!
Stars: ✭ 3,689 (+14656%)
Mutual labels:  maps
urlshort
Ex 2 - Create an http.Handler that forwards paths to other URLs
Stars: ✭ 114 (+356%)
Mutual labels:  maps
jsfiddle-github
JSFiddle implementation for interactive JavaScript examples.
Stars: ✭ 16 (-36%)
Mutual labels:  maps
mapgen
map generator stuff
Stars: ✭ 26 (+4%)
Mutual labels:  maps
rspatial-map-challenge-2020
A list of maps created for #30DayMapChallenge using #rspatial
Stars: ✭ 61 (+144%)
Mutual labels:  maps
react-map-gl-cluster
Urbica React Cluster Component for Mapbox GL JS
Stars: ✭ 27 (+8%)
Mutual labels:  maps

react-google-map npm license

React component to render a Google Map with markers. You can use all official Google Maps API features.

https://developers.google.com/maps/documentation/javascript/reference

react-google-map example

Install

npm install --save react-google-map

If you don't have a solution to load googleMaps, you could use this package:

npm install --save react-google-maps-loader

Changelog

See changelog

Demo

http://cedricdelpoux.github.io/react-google-map/

Usage

.map {
  height: 300px;
}

@media screen and (min-width: 1024px){
    .map {
        height: 500px;
    }
}
import React, {PropTypes} from "react"

import GoogleMap from "react-google-map"
import GoogleMapLoader from "react-google-maps-loader"

import iconMarker from "./assets/iconMarker.svg"
import iconMarkerHover from "./assets/iconMarkerHover.svg"

import styles from "./index.css"

const MY_API_KEY = "AIzaSyDwsdjfskhdbfjsdjbfksiTgnoriOAoUOgsUqOs10J0" // fake

const Map = ({googleMaps}) => (
  // GoogleMap component has a 100% height style.
  // You have to set the DOM parent height.
  // So you can perfectly handle responsive with differents heights.
  <div className={styles.map}>
    <GoogleMap
      googleMaps={googleMaps}
      // You can add and remove coordinates on the fly.
      // The map will rerender new markers and remove the old ones.
      coordinates={[
        {
          title: "Toulouse",
          position: {
            lat: 43.604363,
            lng: 1.443363,
          },
          onLoaded: (googleMaps, map, marker) => {
            // Set Marker animation
            marker.setAnimation(googleMaps.Animation.BOUNCE)

            // Define Marker InfoWindow
            const infoWindow = new googleMaps.InfoWindow({
              content: `
                <div>
                  <h3>Toulouse<h3>
                  <div>
                    Toulouse is the capital city of the southwestern
                    French department of Haute-Garonne,
                    as well as of the Occitanie region.
                  </div>
                </div>
              `,
            })

            // Open InfoWindow when Marker will be clicked
            googleMaps.event.addListener(marker, "click", () => {
              infoWindow.open(map, marker)
            })

            // Change icon when Marker will be hovered
            googleMaps.event.addListener(marker, "mouseover", () => {
              marker.setIcon(iconMarkerHover)
            })

            googleMaps.event.addListener(marker, "mouseout", () => {
              marker.setIcon(iconMarker)
            })

            // Open InfoWindow directly
            infoWindow.open(map, marker)
          },
        }
      ]}
      center={{lat: 43.604363, lng: 1.443363}}
      zoom={8}
      onLoaded={(googleMaps, map) => {
        map.setMapTypeId(googleMaps.MapTypeId.SATELLITE)
      }}
    />
  </div>
)

Map.propTypes = {
  googleMaps: PropTypes.object.isRequired,
}

export default GoogleMapLoader(Map, {
  libraries: ["places"],
  key: MY_API_KEY,
})

Props

  • autoFitBounds: Boolean - Enable it if you will add and remove markers on the fly. Bounds will fit automatically
  • boundsOffset: Number - If autoFitBounds enabled you want custom bounds, - by default is 0.002
  • coordinates: Array of Marker props. You can use all props defined in google.maps.MarkerOptions object specification (https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions). If you need some google.maps constants, use the onLoaded prop (onLoaded: (googleMaps, map, marker) => {}) to update your map and markers - by default is []
  • googleMaps: Object - injected by placesLoader,
  • onLoaded: Function with two parameters (onLoaded: (googleMaps, map) => {}),

You can use all props defined in google.maps.MapOptions object specification: https://developers.google.com/maps/documentation/javascript/reference#MapOptions

If you need some google.maps constants, use the onLoaded prop

Development

Clean lib folder

npm run clean

Build lib folder

npm run build

Watch src folder

npm run watch

Lint src folder

npm run lint

License

See MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].