Skip to content

Commit

Permalink
Reuse single map instance object (#6)
Browse files Browse the repository at this point in the history
* Allow gmap option props to be changed dynamically (google-map-react#215)

* 0.17.0

* Reset Bounds when surrounding div resizes (google-map-react#219)

* added listeners for element/map resize event

* changed names accordingly

* added eslint-disabled to pass through travis checks

* changes for travis checks

* added eslint disables

* disabling eslint for lNo 906

* removed trailing spaces

* removed unnecessary id and refs

* removed eventListners on unMount

* 0.18.0

* Fix incorrect onChildMouseDown is called when marker is already removed

* 0.18.1

* fixes google-map-react#220 (google-map-react#222)

* 0.18.2

* Bump babel to version 6.14.0 (google-map-react#224)

* 0.18.3

* Update README with ES6 Promise instructions (google-map-react#231)

* Fix ipad dragging issue (google-map-react#233)

* Fix ipad dragging issue

* Limit touch events to map only

* 0.19.0

* Fix unreliable `window` and `document` detection (google-map-react#246)

* Fix unreliable DOM availability detection to more robust approach

Signed-off-by: Viktor Bezděk <viktor.bezdek@siteone.cz>

* Temporarily commit compiled files to repo before pull request google-map-react#246 gets published to fix ssr issues

Signed-off-by: Viktor Bezděk <viktor.bezdek@siteone.cz>

* Revert "Temporarily commit compiled files to repo before pull request google-map-react#246 gets published to fix ssr issues"

This reverts commit 7e19a86.

* 0.19.1

* Fix, I see no reason now to prevent mouseDown event propagation (google-map-react#248)

* 0.20.0

* Closes google-map-react#260

* 0.20.1

* #add layerTypes props handler, and GMapLayers view (google-map-react#264)

* #add layerTypes props handler, and GMapLayers view

* #fix linter, change props place

* #add layerTypes props descrition

* 0.21.0

* Fixed componentWillReceiveProps options function bug (google-map-react#273)

Fixes a bug which prevented you from changing the function passed to
the options prop

* doc: clarify `onClick` and `onChange` arg structure (google-map-react#241)

More clearly show that `onClick` and `onChange` take
objects as arguments.

* 0.21.1

* 0.21.2

* #add handlers for fly update layers (google-map-react#272)

* #add handlers for fly update layers

* #remove force param

* Update google_map.js

* 0.21.3

* expose map type callback (google-map-react#275)

* Keep original center on _mapDomResizeCallback (google-map-react#282)

When the resize event is triggered, the original center was lost. 
This issue is significant when the map is renders outside visible dom with zero height and width.
When placed into the visible dom, the resize is triggered correctly. With this change the center will persist. (Without this fix the old center is the top left corner)

* 0.21.4

* Fix reference to maps instead of map. (google-map-react#283)

Sorry, made a smal but ugly mistake in the last pull request.
The this.maps does not have a function getCenter .... but this.map does

* 0.21.5

* Add ne and sw to bounds object (google-map-react#287)

* Add ne and sw to bounds object

* Add ability to use ne and sw in fitBounds

* Return all corners from fitBounds

* Remove exports object in favour export

* 0.22.0

* fix small typo (add -> remove) (google-map-react#295)

* 0.22.1

* Fix remove listener

* 0.22.2

* Fix google api bug

* 0.22.3

* adding note about `resetBoundsOnResize` to readme (google-map-react#307)

closes google-map-react#306

* Update README.md

* New documentation begin

* Add information

* Additions

* typos

* Thank you

* Add in progress

* Add why

* Fix

* typo

* Examples

* onChild* examples

* no message

* Update DOC.md

* Add AnyReactComponent with jsbin example (google-map-react#320)

* Add AnyReactComponent with jsbin example

* Fix

* Link

* Reformat sections

* Small fixes

* Stop capturing all touch events and use built in google maps support (google-map-react#334)

* Revert "Fix ipad dragging issue (google-map-react#233)"
Using the built in support from google maps would make the component more
mobile friendly.

This reverts commit 7d1180c.

* Improve documentation around touch device support

* Fix linting errors

* Fix unresponsive map after outside-click on a touch device with draggable:false (google-map-react#335)

* Implement workaround fix for mouseout event on touch devices

* fix linting errors

* 0.23.0

* Update DOC.md

* Update DOC.md

* Move 2 yarn, add prettier, update linters (google-map-react#360)

* Move 2 yarn, add prettier, update linters

* Fix linting error

* 0.24.0

* Add issue template

* Add source to clustering example (google-map-react#311)

* Added react 16 as peer dependency + bumped related react versions (google-map-react#454)

* react-16 added react 16 as peer dependency and bumped related react versions

* react-16 removed unwanted style changes

* react-16 removed unwanted style changes

* react-16 removed unwanted style changes

* 0.25.0

* Update README.md

* Update README.md

* Update README.md

* Move points-geometry dependency to organization (google-map-react#462)

* Move dependency to organization

* Update geo.js

* Update transform.js

* Update API.md (google-map-react#403)

fix searchbox example

* docs - fix outdated method on SearchBox example (google-map-react#343)

* Fix markers position on fullscreen mode (google-map-react#452)

* Remove sensor parameter (google-map-react#399)

https://stackoverflow.com/questions/8616764/what-is-the-sensor-parameter-in-google-places-api-good-for

* Upgrade to 0.26.0 (google-map-react#481)

* Update yarn.lock (google-map-react#483)

google-map-react@e344c3c
switched from `point-geometry` to `@mapbox/point-geometry`, but it
didn't update yarn.lock accordingly. This does.

* Make `resetBoundsOnResize` preserve center when full-screened (google-map-react#482)

* lockCenter prop added

* Resolve conflicts

* Fix lint with `yarn lint --fix`

* Add documentation for `lockCenter` prop

* Remove `lockCenter`, add its behavior to `resetBoundsOnResize`

See https://github.com/istarkov/google-map-react/pull/482/files#r158330791

* notify call back of load failure (google-map-react#479)

When the google  fails to load due to no internet, the  call back should be notified so that appropriate UI can be shown

* Travis: Ensure that yarn.lock is up to date (google-map-react#487)

See google-map-react#483 (comment)

* Add fullscreen check for Internet explorer 11 (google-map-react#485)

* Add fullscreen check for Internet explorer 11

Fixing marker position in Internet Explorer 11 in fullscreen mode.
Fixing: google-map-react#484

* google-map-react#484: move fullscreen check to function

* google-map-react#484 eslint fix

* Move to use of prop-types package for PropTypes (google-map-react#398)

* Create GMap.js

* Create GMapLayers.js

* Create GMapResizable.js

* Create SimpleMarker.js

* Upgrade version to 0.27.0 (google-map-react#489)

* Fix for usage from China (google-map-react#494)

* Fix for usage from China

* Fix formatting

* Case insensitive check for China region

* Add localization info to docs, incl info regarding China specific URL

* Update version to 0.28.0 (google-map-react#495)

- Adds support for China

* Fix China fix making region required (google-map-react#496)

* Upgrade version to 0.29.0 (google-map-react#499)

Fixes current release where region is required and it should be not.

* Added heatmap functionality (google-map-react#441)

* Added functionality of heatmap

* Added options for heatmap

* default heatmap prop change to object

* resolve linting issues

* resolve linting

* Added demo for heatmap

* Fixed eslint

* Added heatmapLibrary prop for enable and disable visualization library for components

* Fixed linting

* Added heatmapLibrary={true} in all map components

* Fixed proptypes error

* Added heatmap in README with example code

* removed api key from heatmap component

* Removed unnecessary props from heatmap component

* Bump version to 0.30.0

* Update README.md (google-map-react#509)

* Update README.md

Switch the position of heatmap info and remove some unnecessary attributes

* Update README.md

* Bump version to 0.31.0

* Added loose to es2015 for IE10, IE11 support (google-map-react#504)

* added intellij ide gitignore

* IE9 and IE10 require loose to work

your demo app doesn't work on IE9/10 so you will need to make a more simple one to test this fix out. the issue is to do with this.props not being avaiable in constructors for IE9/10 see: babel/babel#3975 it was supposidly fixed 1 year ago but I can't see it working, maybe we need to swap to @babel/core to get this fix? I tried it but the change is made larger due to the curent demo apps build system.

Full fix would involve upgading to @babel/core + @babel/preset-env and migrating away from kotatsu in favour of a plain ole react app via webpack (create-react-app maybe?) and then place it into another folder and have that folder habing it's own package.json so we can consume google-map-react as if it were a real library during testing. Sure we would loose hmr, but at this stage hmr isn't all that useful anyway.

I'de love the proper fix, but for now I have clients with IE10 browser requirements.

* fix error about fromLatLngToDivPixel (google-map-react#517)

* fix error about fromLatLngToDivPixel

fix "Cannot read property 'fromLatLngToDivPixel' of undefined" google-map-react#257

* skip only the code that relates to div or overlay

* Bump version to 0.32.0 (google-map-react#519)

Bumping version to 0.32.0

* Accept 0 as zoom value. (google-map-react#525)

* Accept zoom being 0

* If we set a minZoom, its clear that we want to override it

* Oops! Wrong operators

* Update package.json (google-map-react#529)

* Set latest release version as default if user does not specify a version. (google-map-react#530)

* Move URL logic to a better place

* DRY

* Set release version as default version

* Actually, lets be careful and set v to 3.31

* upgrade .babelrc (google-map-react#521)

* upgrade .babelrc

* yarn.lock

* Update .babelrc

Fix format.

* call zoomControlClickTime on all clicks (google-map-react#211)

* call zoomControlClickTime on all clicks

* Update google_map.js

* Update package.json (google-map-react#531)

Bumps version to 0.34

* Refactor code style (google-map-react#533)

* Run eslint

* Avoid DRY in importing

* Update recompose

* Unnecessary backticks

* Update comments

* Move api-path into a variable

* Rename queryString to params

* Proper eslint-disable

* Use private createHelper from recompose as its not exposed (google-map-react#537)

* Remove lodash and use our own utils (google-map-react#535)

* Use pure reduce and map functions

* Use only isEmpty from lodash

* Create our own isEmpty, don't use lodash

* Normalize utils names

* Group utils together

* Proper checking, better this way

* Set default value to options

* Use shallowEqual and isEmpty as much as possible (google-map-react#540)

* Use shallowCompare to compare objects

* Use isEmpty as much as possible

* Use our own shallowEqual

* Remove fbjs

* Just disable necessary line

* Add eslint-disable where needed

* Fix recompose (google-map-react#547)

* Create our own createHelper, its not in recompose anymore

* Use our withStateSelector

* Proper apiKey usage

* Replace apiKey with bootstrapUrlKeys

* No need of true value in html

* Use lodash.omit instead in dev

* Remove unused file

* Remove unnecessary extra folder utils

* Upgrade recompose again

* Oops! Move lodash.omit to devDependencies

* Fix webpack files styles

* Make examples bigger in width

* Improve documentation (google-map-react#548)

* Move heatMap docs to API.md

* Upgrade example code style

* Specify that we need a container in the example

* Actually, remove propTypes, will confuse ppl

* Add more instructions

* Add main title

* Quick corrections

* Add PRs welcome status

* Move features down

* Actually, lets not use PFC, will avoid confusions

* Remove center from tips, its obvius

* Remove bower message, not needed I believe

* Clearer documentation

* Use our own omit.js (google-map-react#561)

* added if statement in onRemove() function (google-map-react#555)

Added an if statement in onRemove() function that checks if "this.div" is defined before calling ReactDOM.unmountComponentAtNode(this.div). This is done to avoid throwing an "unmountComponentAtNode(...): Target container is not a DOM element" error. I ran into this error while using google-map-react with React Router and switching between tabs rapidly to stress test my application.

* Move links to org instead of Ivan's repo, they were broken (google-map-react#563)

* Oops! Fix typo

* Fix code styling in develop (google-map-react#564)

* Fix zoom animation for v3.32 (google-map-react#559)

* Use the experimental version, to get the new zoom animation.

* Don't use bounds for rendering in 3.32

* Revert the project() and unproject() methods.

Instead, add a new method fromLatLngToContainerPixel() to geo service.

* No need of setting .exp, that is by default

* Comments explaining the significance of API v3.32

* Add _VERSION to const

* Release 1.0.0

* added feature to add weights to the heatmap (google-map-react#572)

* Bump version to 1.0.1

* Use new apiKey

* Update Readme.md

Fix example

* Move react-dom to dependencies (google-map-react#577)

* Move react-dom to dependencies

* Actually, move react-dom to peer-dependency

* Move react-dom from peer to dependencies

* Bump to 1.0.2

* Fix README.md

* Update Readme jsbin examples (google-map-react#578)

* Fix GH pages

* Option to position and size components with two corners. (google-map-react#580)

* Option to position components with two corners.

This lets you lock a component to a specific bounding rectangle, which allows for precise tiling during zoom.

* Add a comment explaining two point positioning.

* Bump to v1.0.3 (google-map-react#582)

* Avoid null error (google-map-react#570)

Avoid the error "Cannot read property 'removeEventListener' of null"

* Add guard around mapDom event listener (google-map-react#594)

Fixes an issue where, even if the end user has a proper google maps API
mock, the GoogleMaps component will throw an error when in a test
env.  ReactDOM.findDOMNode(this.googleMapDom_) returns `null`.

This commit wraps the subsequent addEventListener call in an `if` block,
ensuring that an empty DOM doesn't add complications to test suites

* Move dep for react-dom (google-map-react#592)

* Update API.md (google-map-react#596)

* Bump version to 1.0.4 (google-map-react#598)

* Update 'positioning a marker' docs (google-map-react#599)

Better way to position a marker

* Update API.md (google-map-react#600)

* Fix build (google-map-react#605)

* Fix build by updating yarn

* Fix lint

* Fix build by adding react-dom to devDependencies

* Fix lint again

* Update API.md (google-map-react#606)

Because the parent node of marker has size 0x0, top 50% and right 50% would affect nothing. You only need to translate(-50%, -50%) to move it to the right position.

* Remove marker jiggle. (google-map-react#603)

Position the markers relative to the map panes.
Don't position the element that contains the markers.
Renamed all the geo service projection methods, for clarity.

* Upgrade version to 1.0.5 (google-map-react#607)

* Update API.md (google-map-react#611)

Since June 11 2018 all Google Maps Platform API requests must include an API key.
https://developers.google.com/maps/documentation/javascript/usage-and-billing

* Fix typo, and call fromContainerPixelToLatLng() as you would expect. (google-map-react#620)

* Add prop `onTilesLoaded` (google-map-react#615)

* Add prop `onTilesLoaded`

* (Adjust package name

* Increase version

* Make linter happy

* Remove scope from package name and reset version number

* Add description for new prop

* Remove "directories" entry

* Correct changelog

* Remove section header

* v2.0.0

* Revert version number

* Only listen to event if prop is used

* Bump version to 1.0.6 (google-map-react#621)

* Fix old examples links and add one to new examples (google-map-react#633)

* Use React 16 portal to render map overlay (google-map-react#643)

* Use React 16 portal to render map overlay

This allows the new context API to propagate context properly.

* Rename div to overlay

* Add passive scroll (google-map-react#631)

* Add passive scroll

* Reworked code

* Bump version to 1.0.7 (google-map-react#644)

* Revert 643 fix/map context (google-map-react#645)

* Revert "Bump version to 1.0.7 (google-map-react#644)"

This reverts commit 800092a.

* Revert "Add passive scroll (google-map-react#631)"

This reverts commit 40c8f67.

* Revert "Use React 16 portal to render map overlay (google-map-react#643)"

This reverts commit b121bb6.

* Bump version to 1.0.8 (google-map-react#646)

* Custom div style options (google-map-react#634)

* Custom div style options

* fix es-lint issue

* props naming fix

* docs update

* words

* Bump version to 1.0.9 (google-map-react#651)

* add math abs to avoid negative values when calculating zoom (google-map-react#655)

* add math abs to avoid negative values when calculating zoom

* add math.abs with proper styling to pass tests

* add math.abs to dx\dy on fitbounds

* Pass map instance to onDrag handler (google-map-react#656)

* Added feature: update heat map on data change + fix linting (google-map-react#593)

* Added feature: update heat map on data change

When prop updateHeatmap is set to true --> map will rerender.
- New render of <GoogleMapReact> and data is changed, prop updateHeatmap should be true
- New render of <GoogleMapReact> and data is not changed, prop updateHeatmap should be false

* Supports multiple google map libraries + update heatmap when prop updateHeatmap equals true

* Updated this.props -> nextProps (rookie mistake...)

* Updated API documentation:
- added info about the use of other libraries in the Google Map API
- added info about the updateHeatmap prop

* Bump version to 1.1.0 (google-map-react#671)

This includes: 

- google-map-react#655 Add math abs to avoid negative values when calculating zoom 
- google-map-react#656 Pass map instance to onDrag handler 
- google-map-react#593 Added feature: update heat map on data change + fix linting

* Revert "Added feature: update heat map on data change + fix linting" (google-map-react#679)

* Revert "Bump version to 1.1.0 (google-map-react#671)"

This reverts commit 1603e3a.

* Revert "Added feature: update heat map on data change + fix linting (google-map-react#593)"

This reverts commit 1ce8726.

* Bump to 1.1.1 (google-map-react#680)

Bump to 1.1.1

* Added React 16 createPortal with backwards compatibility (google-map-react#696)

* added react 16 createPortal support with backwards compatibility

* fixed lint errors

* Bump version to 1.1.2 (google-map-react#697)

Bump version to 1.1.2

* Update README.md (google-map-react#698)

* Update README.md

* Update README.md

* Update README.md

* Add javascript tag

* Update README.md

* Update README.md

* Small fix API.md (google-map-react#721)

It is small fix in the example for Positioning a marker

* Documentation: added PropTypes for heatmap prop (google-map-react#716)

* Documentation: added PropTypes for heatmap prop

This PR improves the documentation of the heatmap prop by adding types.
I don't mind adding PropTypes validation to this prop as well if you are interested in that.

* Update API.md

I added some spacing between the interface and the example snippet.
I also added a link to the example I wrote for the other repository. I think we should delay this PR until that example is live. That way, the new Demo link will go to live functioning code rather than no where.

* Add shouldUnregisterMapOnUnmount prop to persist map object on unmount (google-map-react#722)

* Google Map loader respecting the app language change (google-map-react#726)

* Bump version to 1.1.3

* Fix: Update heatmap layer when heatmap positions prop changes (google-map-react#728)

* improvement: switched from defining API key in multiple places to one place

* now generating random readings

* fix: a change in heatmap positions now updates the map accordingly

* docs: added comment to explain that the developer should use their own key

* Revert "Bump version to 1.1.3"

This reverts commit 59c0265.

* Bump version to 1.1.3

* Revert "Google Map loader respecting the app language change (google-map-react#726)" (google-map-react#738)

This reverts commit 55fd1b0.

* Revert "Add shouldUnregisterMapOnUnmount prop to persist map object on unmount (google-map-react#722)" (google-map-react#739)

This reverts commit 40fe3ea.

* Bump version to 1.1.4

* Pass zoom value to zoom animation callbacks (google-map-react#742)

* Update DOC.md

* Update DOC.md

* Remove scam links

* Add UNSAFE_ prefix to deprecated lifecycle methods (google-map-react#778)

* add UNSAFE_ prefix to deprecated lifecycle methods

* add missing line break

* Move prop-types to dependencies (google-map-react#769)

* Add prop 'onDragEnd' (google-map-react#754)

* Add shouldUnregisterMapOnUnmount prop to persist map object on unmount (google-map-react#759)

* Update package.json

* Update ISSUE_TEMPLATE to avoid uncomplete issues

* Add .lock file

* Update README.md (google-map-react#826)

Let's not call the default Google Map components "ugly", lots of time and effort went into designing them I'm sure.

* Updated China base url (google-map-react#827)

* Update package.json

* Add dev folders into .npmignore (google-map-react#835)

* Include updated example of clustering using hooks (google-map-react#823)

Include an example of clustering which loads/clusters remote data using hooks and modern React techniques.

* Update version to 1.1.7

* Update License and Readme (google-map-react#895)

* Update License and Readme

Co-authored-by: Roman Kovtun <gyto23@gmail.com>
Co-authored-by: Michael Diego <6419886+itsmichaeldiego@users.noreply.github.com>

* Update dependencies and fix develop env (google-map-react#897)

* Upgrade packages
* Update yarn.lock
* Fix warnings
* Fix sass dependencies
* Fix sass modules

* Fix vulnerabilities (google-map-react#899)

* Fix eslint's vulnerabilities
* Fix mocha's vulnerabilities

* Rewrite library using create-react-library (google-map-react#900)

* Rewrite library using create-react-library
* Export utils properly
* Remove unnecessary code and fix eslintignore
* Update CHANGELOG

* 2.0.0

* Update CHANGELOG.md based on releases

* Moves marker dispatcher binds to componentDidMount (google-map-react#873)

* On resize it's getting undefined minZoom (google-map-react#864)

* Update CHANGELOG

* 2.0.1

* Fix options not updated bug (google-map-react#878)

Co-authored-by: Michael Diego <6419886+itsmichaeldiego@users.noreply.github.com>

* 2.0.2

* Fix default imports

* Update CHANGELOG

* 2.0.4

* Update README.md

* 2.0.8

* Add guide to manually link local module to README (google-map-react#912)

* Added all google maps api libraries to api loader (google-map-react#921)

* Added all google maps api libraries to api loader

Supports places, visualization, places, and geomerty libs.
keeps support for previous heatMapLibrary prop to avoid breaking older usage.

* add libraries to props of GoogleMap

* Update google_map.js

* add warning about heatMapLibrary

* heatmap depreaction, clean libraries, docs

* clean up google map prop

* Update CHANGELOG

* 2.1.0

* Update API.md

* Fix heatmapLibrary

* 2.1.2

* Produce CommonJS and UMD bundles (google-map-react#932)

* Reverts PR google-map-react#921 to fix google-map-react#931 (google-map-react#933)

* Revert "Fix heatmapLibrary"

This reverts commit 8e67c08.

* Revert "Update API.md"

This reverts commit 2d55ced.

* Revert "Added all google maps api libraries to api loader (google-map-react#921)"

This reverts commit 1718a4a.

* 2.1.3

* Update yarn.lock

* Use @googlemaps/js-api-loader and fix libraries usage (google-map-react#946)

Co-authored-by: Justin <jpoehnelt@google.com>
Co-authored-by: Aviya Developer <aviya.developer@gmail.com>

* 2.1.4

* Fix examples infinite loop

* Fix key not being set in bootstrapURLKeys (google-map-react#948)

* 2.1.5

* Change componentWillReceiveProps to componentDidUpdate (google-map-react#950)

* 2.1.6

* Avoid multiple api loads (google-map-react#955)

* 2.1.7

* build(deps): update @googlemaps/js-api-loader (google-map-react#958)

* build(deps): update @googlemaps/js-api-loader

* chore: include update yarn.lock

* 2.1.8

* Fix google-map-react#954: Use single instance of Loader (google-map-react#968)

* Use single instance of Loader
* Update @googlemaps/js-api-loader

* 2.1.9

* Bump y18n from 4.0.0 to 4.0.1 (google-map-react#1017)

Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: update peer deps for react (google-map-react#1028)

* feat: update peer deps for react

* fix: remove package-lock

* fix: update yarn lock

* allow 16 or 17

* Update CHANGELOG

* Update CHANGELOG

* 2.1.10

* Update README.md

* Add Atlist sponsor text to README

* Add mapInstance util and use in main

* Fix import path

* Add scripts

* Update dist

* Cleanup cwu

* Update dist

* Remove util

* Remove unused function

* Add todo

* Revert "Add todo"

This reverts commit bd2419a.

* Add todo

Co-authored-by: alex-e-leon <alex-e-leon@users.noreply.github.com>
Co-authored-by: cybice <istarkov@gmail.com>
Co-authored-by: Rupesh Singh <im.singh.rupesh@gmail.com>
Co-authored-by: joaovpmamede <joaovpmamede@gmail.com>
Co-authored-by: Jop de Klein <jop@validweb.nl>
Co-authored-by: Martin Jujou <mjujou@gmail.com>
Co-authored-by: Viktor Bezdek <viktor.bezdek@siteone.cz>
Co-authored-by: Ivan <iqsk81ad@gmail.com>
Co-authored-by: Kevin Donahue <kevindonahuedevelopment@gmail.com>
Co-authored-by: Matt Dean <matt.thomas.dean@gmail.com>
Co-authored-by: Andries Smit <mr.andries.smit@gmail.com>
Co-authored-by: Lukyanov Fedor <lukyanov.f.ua@gmail.com>
Co-authored-by: Marius Andra <marius.andra@gmail.com>
Co-authored-by: Chris Drackett <chris@chrisdrackett.com>
Co-authored-by: Yoad Snapir <yoadsn@users.noreply.github.com>
Co-authored-by: Lloyd Watkin <lloyd@evilprofessor.co.uk>
Co-authored-by: Exomnius <janssen_cornel@hotmail.com>
Co-authored-by: Michael Diego <6419886+itsmichaeldiego@users.noreply.github.com>
Co-authored-by: valorize <github@valoric.de>
Co-authored-by: Tim <darknelmail.com@yandex.ru>
Co-authored-by: huygn <gnhuy91@gmail.com>
Co-authored-by: jbcochery <jbcochery@users.noreply.github.com>
Co-authored-by: comerc <comerc@users.noreply.github.com>
Co-authored-by: Joseph Frazier <1212jtraceur@gmail.com>
Co-authored-by: Acellam Guy <abiccel@yahoo.com>
Co-authored-by: Ondrej Mladek <ondrej.mladek@actum.cz>
Co-authored-by: David Furlong <dvfurlong@googlemail.com>
Co-authored-by: Emil Pålsson <emil@emilpalsson.se>
Co-authored-by: ZAKdev <zainahmedkhan@gmail.com>
Co-authored-by: falconmick <falconmick@users.noreply.github.com>
Co-authored-by: Fumiya Karasawa <krswfmy@gmail.com>
Co-authored-by: alireza valizade <alirezavalizade0@gmail.com>
Co-authored-by: kal <kal17da@gmail.com>
Co-authored-by: Stephen Farrar <stephenfarrar@users.noreply.github.com>
Co-authored-by: Michael Diego <itsmichaeldiego@gmail.com>
Co-authored-by: Donovan De Smedt <donovan.desmedt@delawareconsulting.com>
Co-authored-by: Matt Togstad <mtogstad@gmail.com>
Co-authored-by: Alexander Sundli-Härdig <alexander@sundli-hardig.no>
Co-authored-by: Jeffrey Auriemma <bignimbus@users.noreply.github.com>
Co-authored-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
Co-authored-by: Ryan Vermooten <ryanvermootenbackup@gmail.com>
Co-authored-by: Jonathan Weiß <info@jonathanweiss.net>
Co-authored-by: Curtis Layne <curtis.s.layne@gmail.com>
Co-authored-by: Jurgis Kacens <jurgis.kacens@outlook.com>
Co-authored-by: Max Chernin <13330924+maxchernin@users.noreply.github.com>
Co-authored-by: Dmitry Bogomya <dmitry.bogomya@gmail.com>
Co-authored-by: Artem Artemyev <viiv.c58@gmail.com>
Co-authored-by: Artem <shariukov.artem@mail.ru>
Co-authored-by: Michael Salaverry <barakplasma@gmail.com>
Co-authored-by: Kevin Ramsunder <kevinramsunder4@gmail.com>
Co-authored-by: Tom Wagner <tomas.wagner@gmail.com>
Co-authored-by: Eric Neo <eric@eric-neo.com>
Co-authored-by: Joe Maffei <joemaffei@users.noreply.github.com>
Co-authored-by: Jeffrey Cherewaty <jeffrey@cherewaty.com>
Co-authored-by: Kevin Ramsunder <kevinramsunder5@gmail.com>
Co-authored-by: Paito Anderson <pj.paito@gmail.com>
Co-authored-by: Eniz Gülek <enizgulek@gmail.com>
Co-authored-by: Giulio G <giulio.gallerini.work@hotmail.com>
Co-authored-by: Leigh Halliday <leighhalliday@gmail.com>
Co-authored-by: Roman Kovtun <54277098+gyto23@users.noreply.github.com>
Co-authored-by: Roman Kovtun <gyto23@gmail.com>
Co-authored-by: Brandon DeMello <bdell@users.noreply.github.com>
Co-authored-by: Afzal Hossain <afzal.csedu@gmail.com>
Co-authored-by: Dirk Rusche <dirk@rusche.me>
Co-authored-by: Agustin Lessa <aguslessat@gmail.com>
Co-authored-by: aviyadeveloper <43666444+aviyadeveloper@users.noreply.github.com>
Co-authored-by: Justin <jpoehnelt@google.com>
Co-authored-by: Aviya Developer <aviya.developer@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Storck <ivanoats@users.noreply.github.com>
Co-authored-by: Karl Danninger <karl@danninger.co>
  • Loading branch information
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 65 deletions.
103 changes: 55 additions & 48 deletions README.md
Expand Up @@ -2,7 +2,7 @@

`google-map-react` is a component written over a small set of the [Google Maps API](https://developers.google.com/maps/). 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](http://google-map-react.github.io/google-map-react/map/main) *(You can scroll the table, zoom/move the map, hover/click on markers, and click on table rows)*
It allows you to create interfaces like this [example](http://google-map-react.github.io/google-map-react/map/main) _(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](https://www.atlistmaps.com?c=google-map-react). Atlist is a no-code tool for creating custom maps with multiple markers.

Expand All @@ -13,33 +13,29 @@ In the simple case you just need to add `lat` and `lng` props to any child of `G
[See it in action at jsbin](https://jsbin.com/ruwogapuke/1/edit?js,output)

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

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

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

return (
// Important! Always set the container height explicitly
<div style={{ height: '100vh', width: '100%' }}>
<GoogleMapReact
bootstrapURLKeys={{ key: "" }}
bootstrapURLKeys={{ key: '' }}
defaultCenter={defaultProps.center}
defaultZoom={defaultProps.zoom}
>
<AnyReactComponent
lat={59.955413}
lng={30.337844}
text="My Marker"
/>
<AnyReactComponent lat={59.955413} lng={30.337844} text='My Marker' />
</GoogleMapReact>
</div>
);
Expand All @@ -50,15 +46,16 @@ export default function SimpleMap(){

- 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](https://developers.google.com/maps/documentation/javascript/tutorial).


## Installation

npm:

```
npm install --save google-map-react
```

yarn:

```
yarn add google-map-react
```
Expand All @@ -71,7 +68,7 @@ Instead of the default Google Maps markers, balloons and other map components, y

### 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)*
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

Expand All @@ -81,7 +78,7 @@ It renders components on the map before (and even without) the Google Maps API l

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
### 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`

Expand Down Expand Up @@ -119,42 +116,42 @@ Now every object on the map can be hovered (however, you can still use css hover

## Examples

* Placing react components on the map:
[simple](http://google-map-react.github.io/google-map-react/map/simple/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_simple/simple_map_page.jsx))
- Placing react components on the map:
[simple](http://google-map-react.github.io/google-map-react/map/simple/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_simple/simple_map_page.jsx))

* Custom map options:
[example](http://google-map-react.github.io/google-map-react/map/options/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_options/options_map_page.jsx))
- Custom map options:
[example](http://google-map-react.github.io/google-map-react/map/options/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_options/options_map_page.jsx))

* Hover effects:
[simple hover](http://google-map-react.github.io/google-map-react/map/simple_hover/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_simple_hover/simple_hover_map_page.jsx));
[distance hover](http://google-map-react.github.io/google-map-react/map/distance_hover/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_distance_hover/distance_hover_map_page.jsx))
- Hover effects:
[simple hover](http://google-map-react.github.io/google-map-react/map/simple_hover/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_simple_hover/simple_hover_map_page.jsx));
[distance hover](http://google-map-react.github.io/google-map-react/map/distance_hover/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_distance_hover/distance_hover_map_page.jsx))

* GoogleMap events:
[example](http://google-map-react.github.io/google-map-react/map/events/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_events/events_map_page.jsx))
- GoogleMap events:
[example](http://google-map-react.github.io/google-map-react/map/events/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_events/events_map_page.jsx))

* Example project:
[main](http://google-map-react.github.io/google-map-react/map/main/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_main/main_map_block.jsx)); [balderdash](http://google-map-react.github.io/google-map-react/map/balderdash/) (same source as main)
- Example project:
[main](http://google-map-react.github.io/google-map-react/map/main/) ([source](https://github.com/google-map-react/old-examples/blob/master/web/flux/components/examples/x_main/main_map_block.jsx)); [balderdash](http://google-map-react.github.io/google-map-react/map/balderdash/) (same source as main)

* Clustering example using Hooks (**new**: [source](https://github.com/leighhalliday/google-maps-clustering), [article](https://www.leighhalliday.com/google-maps-clustering)) [clustering-with-hooks](https://google-maps-clustering.netlify.com/)
- Clustering example using Hooks (**new**: [source](https://github.com/leighhalliday/google-maps-clustering), [article](https://www.leighhalliday.com/google-maps-clustering)) [clustering-with-hooks](https://google-maps-clustering.netlify.com/)

* Clustering example ([source](https://github.com/istarkov/google-map-clustering-example))
[google-map-clustering-example](http://istarkov.github.io/google-map-clustering-example/)
- Clustering example ([source](https://github.com/istarkov/google-map-clustering-example))
[google-map-clustering-example](http://istarkov.github.io/google-map-clustering-example/)

* How to render thousands of markers (**new**: [source](https://github.com/istarkov/google-map-thousands-markers))
[google-map-thousands-markers](https://istarkov.github.io/google-map-thousands-markers/)
- How to render thousands of markers (**new**: [source](https://github.com/istarkov/google-map-thousands-markers))
[google-map-thousands-markers](https://istarkov.github.io/google-map-thousands-markers/)

* Examples:
[Examples](https://github.com/google-map-react/google-map-react-examples)
[Old examples](https://github.com/google-map-react/old-examples)
- Examples:
[Examples](https://github.com/google-map-react/google-map-react-examples)
[Old examples](https://github.com/google-map-react/old-examples)

* jsbin example
[jsbin example](https://jsbin.com/ruwogapuke/1/edit?js,output)
- jsbin example
[jsbin example](https://jsbin.com/ruwogapuke/1/edit?js,output)

* webpackbin examples (**new**)
[docs with webpackbin examples](./DOC.md) (In progress)
- webpackbin examples (**new**)
[docs with webpackbin examples](./DOC.md) (In progress)

* local develop example (new)
[develop example](./develop)
- local develop example (new)
[develop example](./develop)

## Documentation

Expand Down Expand Up @@ -185,23 +182,33 @@ 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:
```bash
npm link
```
2. Go into `example/` and (after installing other dependencies) execute:
```bash
npm link google-map-react
```

1. In the root folder:

```bash
npm link
```

2. Go into `example/` and (after installing other dependencies) execute:

```bash
npm link google-map-react
```

## License

[MIT](./LICENSE.md)

## Known Issues

* Older browsers (http://caniuse.com/#feat=promises) will need a ES6 Promise polyfill in order to work.
- Older browsers (http://caniuse.com/#feat=promises) will need a ES6 Promise polyfill in order to work.

## To Do

- Prepare script configured in package.json is not preparing the dist files in production build. Hence, we have pushed the dist folder as a workaround. We need to figure out how to automate the building of dist folder.

## !!! We are looking for contributors

We're actively looking for contributors, please send a message to the Owner or any of the Collaborators.
2 changes: 2 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/index.modern.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.modern.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/index.umd.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.umd.js.map

Large diffs are not rendered by default.

25 changes: 8 additions & 17 deletions src/google_map.js
Expand Up @@ -450,24 +450,13 @@ class GoogleMap extends Component {
this.overlay_.setMap(null);
}

if (this.maps_ && this.map_ && this.props.shouldUnregisterMapOnUnmount) {
// fix google, as otherwise listeners works even without map
this.map_.setOptions({ scrollwheel: false });
this.maps_.event.clearInstanceListeners(this.map_);
}

if (this.props.shouldUnregisterMapOnUnmount) {
this.map_ = null;
this.maps_ = null;
}
this.markersDispatcher_.dispose();

this.resetSizeOnIdle_ = false;

if (this.props.shouldUnregisterMapOnUnmount) {
delete this.map_;
delete this.markersDispatcher_;
}
}

// calc minZoom if map size available
Expand Down Expand Up @@ -615,11 +604,12 @@ class GoogleMap extends Component {
};

mapOptions.minZoom = _checkMinZoom(mapOptions.minZoom, minZoom);

const map = new maps.Map(
ReactDOM.findDOMNode(this.googleMapDom_),
mapOptions
);
const map =
this.props.mapInstance?.init(
ReactDOM.findDOMNode(this.googleMapDom_),
mapOptions
) ||
new maps.Map(ReactDOM.findDOMNode(this.googleMapDom_), mapOptions);

this.map_ = map;
this.maps_ = maps;
Expand Down Expand Up @@ -936,7 +926,8 @@ class GoogleMap extends Component {
this.geoService_.setViewSize(window.innerWidth, window.innerHeight);
} else {
const mapDom = ReactDOM.findDOMNode(this.googleMapDom_);
this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight);
mapDom &&
this.geoService_.setViewSize(mapDom.clientWidth, mapDom.clientHeight);
}
this._onBoundsChanged();
};
Expand Down

0 comments on commit fea8439

Please sign in to comment.