New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added heatmap functionality #441
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, would you mind creating tests and adding an example?
No problem @itsmichaeldiego, i will write tests and add example asap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good generally, I left a couple of comments
develop/GMapHeatmap.js
Outdated
@@ -0,0 +1,103 @@ | |||
/* eslint-disable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we enable eslint
here and fix the errors?
develop/GMapHeatmap.js
Outdated
@@ -0,0 +1,103 @@ | |||
/* eslint-disable */ | |||
import React, { PropTypes } from 'react'; | |||
import compose from 'recompose/compose'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets put everything from recompose in one import as:
import {
compose,
defaultProps,
withHandlers,
withState,
withContext,
withProps,
withPropsOnChange,
} from 'recompose';
develop/GMapHeatmap.js
Outdated
import GoogleMapReact from '../src'; | ||
import SimpleMarker from './markers/SimpleMarker'; | ||
import { createSelector } from 'reselect'; | ||
import { susolvkaCoords, generateMarkers, heatmapData } from './data/fakeData'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets put first global imports and then local imports, meaning that we should have something like:
import React, { PropTypes } from 'react';
import { blablabla } from 'recompose';
import { createSelector } from 'reselect';
import GoogleMapReact from '../src';
import SimpleMarker from './markers/SimpleMarker';
import withStateSelector from './utils/withStateSelector';
import ptInBounds from './utils/ptInBounds';
import { susolvkaCoords, generateMarkers, heatmapData } from './data/fakeData';
src/google_map.js
Outdated
@@ -10,6 +10,7 @@ import MarkerDispatcher from './marker_dispatcher'; | |||
import GoogleMapMap from './google_map_map'; | |||
import GoogleMapMarkers from './google_map_markers'; | |||
import GoogleMapMarkersPrerender from './google_map_markers_prerender'; | |||
import * as GoogleHeatmap from './google_heatmap'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets specify what we want to import, instead of importing everything, just to be sure.
@@ -63,7 +63,7 @@ export default function googleMapLoader(bootstrapURLKeys) { | |||
); | |||
|
|||
$script_( | |||
`https://maps.googleapis.com/maps/api/js?callback=_$_google_map_initialize_$_${queryString}`, | |||
`https://maps.googleapis.com/maps/api/js?callback=_$_google_map_initialize_$_${queryString}&libraries=visualization`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add information of why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visualization
library includes the HeatmapLayer
Here is the reference https://developers.google.com/maps/documentation/javascript/visualization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev That is good, but shouldn't we add this optional if the user sets heatmap as true? Sorry if I am getting it wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego, I can check heatmap prop if its not defined then no need to load visualization
library, but this approach will work only if user has single map on a page because google map api load once for all maps so user may can face some problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev That is a good catch. I am wondering if adding visualization that includes the HeatmapLayer
if we don't want Heatmap would make the performance worse 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev Let me take a look, but what about if the user just set the library when using bootstrapURLKeys
? This is called only once when the map is loaded as it contains the key for it, there you can set for example heatmap: true
and it won't be initialized twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego, this is what i was doing before, but i am assuming a scenario where user has more then one map and any of the map has heatmap at this point it will throw exception because we are initializing map based on user first map.
If first map is the heatmap then every map will work smoothly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev Oh right, so unless we find a workaround we could request the users to set heatmap: true
to every map if they want at least one of the maps to have this functionality. But should we written in the docs for sure.
Otherwise we would have to force the user to share the same bootstrapURLKeys
in all the maps, and that is something we wouldn't want to lose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego i will commit soon for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev You rock!
@itsmichaeldiego, i have added prop called if everything works fine for you so i can add prop |
@ZAKdev Great work man! So the outcome is that we should pass In that case, adding that to the docs would be great, then I will merge this and we can make a new release! |
@itsmichaeldiego i am going to add |
@ZAKdev Awesome dude, let me know and I will merge and make a release! Keep in mind we've some little conflicts with the last PR I merged |
@itsmichaeldiego, i found some issues in |
@ZAKdev Good catch, that has already been fixed, do you mind pulling the latest version and checking again? |
@itsmichaeldiego now we are good to go, you can add |
@ZAKdev Awesome! Thanks!! Changes are looking good, would you mind including that in the README? So that PR handles all the work? LMK and I will merge it asap and publish a new version! |
@itsmichaeldiego, i have added it in README with example code, please let me know if i needs to change something. |
develop/GMapHeatmap.js
Outdated
onChildMouseEnter={onChildMouseEnter} | ||
onChildMouseLeave={onChildMouseLeave} | ||
resetBoundsOnResize={true} | ||
apiKey={'AIzaSyC-BebC7ChnHPzxQm7DAHYFMCqR5H3Jlps'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev What is this apiKey here for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego, we can remove it, its not doing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego, i removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZAKdev If I am not mistaken I believe there are a few more lines that could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsmichaeldiego i removed unnecessary props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great dude! Thanks
Hey guys, any chance we can merge this feature soon? :) |
Yes @calvintychan I am merging it but we will have to test with your heatmaps |
@calvintychan @ZAKdev Merged, could you guys test it out with your heatmaps and let me know? |
Thanks @itsmichaeldiego, I will check everything soon and update you here. Hi @calvintychan, if you need any of guidance for using this feature please feel free to ask, i am available here for help. |
Thanks @ZAKdev, looking forward to it |
@itsmichaeldiego, Heatmap is working as expected 💯 |
@ZAKdev @itsmichaeldiego And what about support locations with weight? Is there any plans to implement it? |
@ribeiroguilherme, Good idea, i didn't really know we can define weight as well, i will add it soon :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi, I have added heatmap functionality which is from default google map api.
How it works
Just need to pass prop of heatmap with GoogleMapReact component and all heatmap options are available like radius, opacity and gradient.
Example