Skip to content
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

Add HeatmapLayer Component #248

Merged
merged 4 commits into from
Sep 29, 2016
Merged

Add HeatmapLayer Component #248

merged 4 commits into from
Sep 29, 2016

Conversation

zolrath
Copy link
Contributor

@zolrath zolrath commented May 7, 2016

Allows a HeatmapLayer to be created. Takes an array of
google.maps.LatLng objects to the prop data.

I'm not sure what events this should really be listening for so if you have any suggestions or things I need to change please let me know!

Allows a HeatmapLayer to be created. Takes an array of
`google.maps.LatLng` objects to the prop `data`.
@cristiandley cristiandley mentioned this pull request May 13, 2016
@cristiandley
Copy link
Collaborator

cristiandley commented May 16, 2016

@zolrath Matt, why are you not using /lib/ for this addon ?

were you able to compile those files and execute these pr ?

im getting Uncaught TypeError: Cannot read property 'HeatmapLayer' of undefined

@cristiandley
Copy link
Collaborator

@zolrath i put your heatmaplayer on my own repo https://www.npmjs.com/package/react-gl-maps just check the /lib/ its missing the babel compilation

@tomchentw tomchentw mentioned this pull request May 29, 2016
@tomchentw
Copy link
Owner

@cristiandley for PRs, it should be clean enough for anyone to see the changes. lib are automatically generated by the release script during publish process.

// https://developers.google.com/maps/documentation/javascript/3.exp/reference#HeatmapLayer
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/^getMap/); })
getData() { return this.state.directionsRenderer.getDirections(); }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

@tomchentw
Copy link
Owner

@zolrath Just left one code review comment. Also, I'd like this component to be under visualization folder instead of addons. addons should be used only for 3rd party components.

Other than that, great work!

@cristiandley cristiandley mentioned this pull request Jun 3, 2016
8 tasks
@zolrath
Copy link
Contributor Author

zolrath commented Jun 6, 2016

I will make the requested changes right now, thanks!
Would you like me to add a visualization folder or put this with the other map overlays such as Markers in src?

@zolrath zolrath changed the title Add HeatmapLayer Addon Add HeatmapLayer Component Jun 7, 2016
@cristiandley
Copy link
Collaborator

@zolrath

Can you add also the radius and opacity properties ?

Thanks and i make my final review

@zolrath
Copy link
Contributor Author

zolrath commented Jun 15, 2016

@cristiandley In the ControlledPropTypes function of the other components I see:

// NOTICE!!!!!!
//
// Only expose those with getters & setters in the table as controlled props.
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#HeatmapLayer

From what I can tell that means I should not expose radius and opacity as they are set in the Options object, not via a getter/setter in the Heatmap?

@tomchentw
Copy link
Owner

@cristiandley let's hold this on for 5.0.0 first?

@cristiandley
Copy link
Collaborator

@tomchentw yes! :)

@ghost
Copy link

ghost commented Jul 5, 2016

Any progress on this?

@zolrath
Copy link
Contributor Author

zolrath commented Aug 19, 2016

What changes need to be done to get this into the new version of react-google-maps?

@tomchentw tomchentw merged commit a1a7b73 into tomchentw:master Sep 29, 2016
@tomchentw tomchentw mentioned this pull request Sep 29, 2016
6 tasks
tomchentw added a commit that referenced this pull request Sep 30, 2016
tomchentw added a commit that referenced this pull request Sep 30, 2016
* Original author: @zolrath
* Ref commits: b8d8623, 21dbb77, 8b16ea4, 08abfb5
* Remove decorator usage in HeatmapLayerCreator
@tomchentw
Copy link
Owner

Released v5.1.0 on npm next tag.

@farhan687
Copy link

Hello everyone,
I am using @beta tag, and I want to use heatmaplayer. I have already tried by wrapping it inside withGoogleMap and also without it, but it's really strange that console shows following error Uncaught TypeError: google.maps.HeatmapLayer is not a constructor.

Here is my implementation:

import { withGoogleMap, GoogleMap, Marker, HeatmapLayer } from "react-google-maps";

<HeatmapLayer
    data = {[
      37.782, -122.447,
     37.782, -122.445
    ]}
  />

Can anyone tell me if I am missing anything?

@matthill1
Copy link

Seconded farhan here, if anybody has successfully implemented the heatmap layer, would you mind posting an example of syntax? The documentation is scarce. Thank you.

@ribeiroguilherme
Copy link

+1 looking for the syntax example as well

@ribeiroguilherme
Copy link

@farhan687 did you figure out how to use? I'm with the same problem here

@ribeiroguilherme
Copy link

ribeiroguilherme commented Dec 16, 2016

Hi guys.
I figured out the problem. In the HeatmapLayer file, is being created the heatmap using:
new google.maps.HeatmapLayer , but this path is incorrect.
It should be
new google.maps.visualization.HeatmapLayer

@ZephD
Copy link

ZephD commented Dec 19, 2016

Even with this change, I get "b.lat() is not a function".
Internally, the visualization library seems to require a google.maps.LatLng, a simple {lat: 0, lng: 0} object does not suffice.
Since google is loaded async, creating new latlngs is very hard. Maybe the HeatmapLayer should convert the data to a LatLng object?

@ribeiroguilherme
Copy link

ZephD, you can create an array like
array.push(new google.maps.LatLng(lat, long)); and pass it to 'data' property in HeatmapLayer.

If you load the google maps script in your index html file, should work fine. Here is working fine.. But we need to fix this bug. When we deploy to production, the node will download the lib with the wrong path.

@ZephD
Copy link

ZephD commented Dec 19, 2016

But I do not have google maps in the index file, because that'll be too easy. Google maps is loaded Async, so I do not have access to new google.maps.LatLng, hence the problem.

See #409.

@GustavoMantuan
Copy link

GustavoMantuan commented Jul 12, 2017

Hello, I am using this way:

import HeatmapLayer from "react-google-maps/lib/visualization/HeatmapLayer";
const MapaPerfilW = withGoogleMap(props => (
    <GoogleMap
        defaultZoom={15}
        center={props.defaultCenter}
    >
        <HeatmapLayer
            data={[
                new google.maps.LatLng(37.782551, -122.445368),
                new google.maps.LatLng(37.782745, -122.444586),
                new google.maps.LatLng(37.782842, -122.443688),
                new google.maps.LatLng(37.782919, -122.442815),
                new google.maps.LatLng(37.782992, -122.442112),
                new google.maps.LatLng(37.783100, -122.441461)
            ]}
        />
    </GoogleMap>
));

Version 7.1.0 working great.

@malindap92
Copy link

malindap92 commented Jul 19, 2017

@GustavoMantuan could you tell me how you were able to access google.maps.LatLng? it gives me 'google' is undefined. Is there any library to import?

@mtpython
Copy link

mtpython commented Jul 20, 2017

@malindap92 add /*global google*/ at the top of your .js file, and the next thing you know - use <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=YOUR_KEY&libraries=visualization"></script> to get the other questions out of the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants