All Projects → google-map-react → Google Map React

google-map-react / Google Map React

Licence: mit
Google map library for react that allows rendering components as markers 🎉

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to Google Map React

Placepicker
Free Android Map Place Picker alternative using Geocoder instead of Google APIs
Stars: ✭ 126 (-97.72%)
Mutual labels:  google, map, maps
react-vector-maps
🗺 A React component for interactive vector maps of the world and 100+ countries
Stars: ✭ 112 (-97.97%)
Mutual labels:  map, maps
NonEmptyCollections
A type-safe implementation for collections that cannot be empty. Life is too short for emptiness-checks!
Stars: ✭ 45 (-99.19%)
Mutual labels:  map, maps
Mappa
A canvas wrapper for Maps 🗺 🌍
Stars: ✭ 290 (-94.75%)
Mutual labels:  google, maps
mapgen
map generator stuff
Stars: ✭ 26 (-99.53%)
Mutual labels:  map, maps
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (-51.4%)
Mutual labels:  map, maps
angular-mapboxgl-directive
AngularJS directive for Mapbox GL
Stars: ✭ 43 (-99.22%)
Mutual labels:  map, maps
leaflet.minichart
Leaflet.minichart is a leaflet plugin for adding to a leaflet map small animated charts
Stars: ✭ 27 (-99.51%)
Mutual labels:  map, maps
Vehicle In Motion
This is a basic implementation of location listener using Google Maps Api
Stars: ✭ 339 (-93.87%)
Mutual labels:  google, maps
Offlinemap
基于MySQL + Node.js + Leaflet的离线地图展示,支持百度、谷歌、高德、腾讯地图
Stars: ✭ 343 (-93.8%)
Mutual labels:  map, maps
Gmscore
Free implementation of Play Services
Stars: ✭ 4,356 (-21.22%)
Mutual labels:  google, maps
react-map-gl-cluster
Urbica React Cluster Component for Mapbox GL JS
Stars: ✭ 27 (-99.51%)
Mutual labels:  map, maps
s60-maps
Yet another maps for Symbian OS
Stars: ✭ 27 (-99.51%)
Mutual labels:  map, maps
o.map
Open Street Map app - KaiOS
Stars: ✭ 51 (-99.08%)
Mutual labels:  map, maps
vaguely-rude-places
The map of Vaguely Rude Place Names
Stars: ✭ 19 (-99.66%)
Mutual labels:  map, maps
map-machine
Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
Stars: ✭ 82 (-98.52%)
Mutual labels:  map, maps
React Native Map Clustering
React Native map clustering both for Android and iOS.
Stars: ✭ 450 (-91.86%)
Mutual labels:  map, maps
Dc Sdk
DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。🌎
Stars: ✭ 206 (-96.27%)
Mutual labels:  google, map
coronavirus-map-dashboard
🦠 Coronavirus (COVID-19) Map Dashboard using coronavirus-tracker-api
Stars: ✭ 41 (-99.26%)
Mutual labels:  map, maps
Maptalks.js
A light and plugable JavaScript library for integrated 2D/3D maps.
Stars: ✭ 3,377 (-38.92%)
Mutual labels:  map, maps

Google Map React · npm version Build Status PRs Welcome

google-map-react is a component written over a small set of the Google Maps API. It allows you to render any React component on the Google Map. It is fully isomorphic and can render on a server. Additionally, it can render map components in the browser even if the Google Maps API is not loaded. It uses an internal, tweakable hover algorithm - every object on the map can be hovered.

It allows you to create interfaces like this example (You can scroll the table, zoom/move the map, hover/click on markers, and click on table rows)

The development of this package is sponsored by Atlist. Atlist is a no-code tool for creating custom maps with multiple markers.

Getting started

In the simple case you just need to add lat and lng props to any child of GoogleMapReact component.

See it in action at jsbin

import React from "react";
import GoogleMapReact from 'google-map-react';

const AnyReactComponent = ({ text }) => <div>{text}</div>;

export default function SimpleMap(){
  const defaultProps = {
    center: {
      lat: 10.99835602,
      lng: 77.01502627
    },
    zoom: 11
  };

  return (
    // Important! Always set the container height explicitly
    <div style={{ height: '100vh', width: '100%' }}>
      <GoogleMapReact
        bootstrapURLKeys={{ key: "" }}
        defaultCenter={defaultProps.center}
        defaultZoom={defaultProps.zoom}
      >
        <AnyReactComponent
          lat={59.955413}
          lng={30.337844}
          text="My Marker"
        />
      </GoogleMapReact>
    </div>
  );
}

My map doesn't appear!

  • Make sure the container element has width and height. The map will try to fill the parent container, but if the container has no size, the map will collapse to 0 width / height. This is not a requirement for google-map-react, its a requirement for google-maps in general.

Installation

npm:

npm install --save google-map-react

yarn:

yarn add google-map-react

Features

Works with your Components

Instead of the default Google Maps markers, balloons and other map components, you can render your cool animated react components on the map.

Isomorphic Rendering

It renders on the server. (Welcome search engines) (you can disable javascript in browser dev tools, and reload any example page to see how it works)

Component Positions Calculated Independently of Google Maps API

It renders components on the map before (and even without) the Google Maps API loaded.

Google Maps API Loads on Demand

There is no need to place a <script src= tag at top of page. The Google Maps API loads upon the first usage of the GoogleMapReact component.

Use Google Maps API

You can access to Google Maps map and maps objects by using onGoogleApiLoaded, in this case you will need to set yesIWantToUseGoogleMapApiInternals to true

...

const handleApiLoaded = (map, maps) => {
  // use map and maps objects
};

...

<GoogleMapReact
  bootstrapURLKeys={{ key: /* YOUR KEY HERE */ }}
  defaultCenter={this.props.center}
  defaultZoom={this.props.zoom}
  yesIWantToUseGoogleMapApiInternals
  onGoogleApiLoaded={({ map, maps }) => handleApiLoaded(map, maps)}
>
  <AnyReactComponent
    lat={59.955413}
    lng={30.337844}
    text="My Marker"
  />
</GoogleMapReact>

PST: Remember to set yesIWantToUseGoogleMapApiInternals to true.

Example here

Internal Hover Algorithm

Now every object on the map can be hovered (however, you can still use css hover selectors if you want). If you try zooming out here example, you will still be able to hover on almost every map marker.

Examples

Documentation

You can find the documentation here:

Contribute

Local development is broken into two parts (ideally using two tabs).

First, run rollup to watch your src/ module and automatically recompile it into dist/ whenever you make changes.

npm start # runs rollup with watch flag

The second part will be running the example/ create-react-app that's linked to the local version of your module.

# (in another tab)
cd example
npm start # runs create-react-app dev server

Now, anytime you make a change to your library in src/ or to the example app's example/src, create-react-app will live-reload your local dev server so you can iterate on your component in real-time.

Manual link-install

If you get the error Module not found: Can't resolve 'google-react-map'... while trying to run the example app, you need to manually link your local development module, try the following steps:

  1. In the root folder:
npm link
  1. Go into example/ and (after installing other dependencies) execute:
npm link google-map-react

License

MIT

Known Issues

!!! We are looking for contributors

We're actively looking for contributors, please send a message to the Owner or any of the Collaborators.

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].