Title: OnClick do not re-render the map · Issue #513 · fullstackreact/google-maps-react · GitHub
Open Graph Title: OnClick do not re-render the map · Issue #513 · fullstackreact/google-maps-react
X Title: OnClick do not re-render the map · Issue #513 · fullstackreact/google-maps-react
Description: Hi, I am trying to run google-map-react in my application. The idea is when I open the page with google maps it should show me a heatmap with all the data. Then I have a dropdown list where I can pick data based on the weekday. So for ex...
Open Graph Description: Hi, I am trying to run google-map-react in my application. The idea is when I open the page with google maps it should show me a heatmap with all the data. Then I have a dropdown list where I can p...
X Description: Hi, I am trying to run google-map-react in my application. The idea is when I open the page with google maps it should show me a heatmap with all the data. Then I have a dropdown list where I can p...
Opengraph URL: https://github.com/fullstackreact/google-maps-react/issues/513
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"OnClick do not re-render the map","articleBody":"Hi,\r\n\r\nI am trying to run google-map-react in my application.\r\nThe idea is when I open the page with google maps it should show me a heatmap with all the data. Then I have a dropdown list where I can pick data based on the weekday. So for example if I pick monday the google map should rerender the map and show me only data for mondays. The map is rendered correctly at the beginning but when I click the button in the dropdown list it doesnt rerender.\r\n\r\nIs this a bug or am I doing something wrong? Hope that anyone can guide me here.\r\n\r\nI have shared my code below. The first code shows the state I am passing to Maps component. The second code is the Maps component.\r\n\r\nFIRST CODE\r\n\r\n```\r\nimport React, { useState, useEffect } from 'react'\r\nimport Map from '../map/Map'\r\nimport data from '../../assets/data/heatmapData'\r\nimport Scatter from \"../scatter-plot/Scatter\";\r\nimport Dropdown from 'react-bootstrap/Dropdown';\r\nimport DropdownButton from 'react-bootstrap/DropdownButton';\r\n\r\nimport './content-section.css'\r\n\r\nconst ContentSection = () => {\r\n const [heatmapData, setHeatmapData] = useState(data);\r\n // useEffect(() => {\r\n // handleWeekday()\r\n // }, [])\r\n\r\n const handleWeekday = (input) => \r\n {\r\n console.log(input);\r\n const heatmapMondayData = [{ lat: 37.782551, lng: -122.44536800000003 },\r\n { lat: 37.782745, lng: -122.44458600000002 },\r\n { lat: 37.782842, lng: -122.44368800000001 },\r\n { lat: 37.782919, lng: -122.442815 }];\r\n\r\n setHeatmapData(heatmapMondayData ); \r\n }\r\n\r\n return (\r\n \u003c>\r\n \u003cdiv className=\"container\">\r\n \u003cdiv className=\"header-text\">This is a header\u003c/div>\r\n \u003cScatter />\r\n \u003cMap center={{ lat: 37.775, lng: -122.434 }} zoom={13} positions={heatmapData} />\r\n \u003cDropdownButton id=\"dropdown-basic-button\" title=\"Dropdown button\">\r\n \u003cDropdown.Item onClick={handleMonday}>Monday\u003c/Dropdown.Item>\r\n \r\n \u003c/DropdownButton>\r\n \u003c/div>\r\n \u003c/>\r\n )\r\n}\r\n\r\nexport default ContentSection\r\n```\r\n\r\nSECOND CODE\r\n```\r\n\r\nimport React, { Component } from \"react\";\r\nimport { Map, HeatMap, GoogleApiWrapper } from \"google-maps-react\";\r\nimport './map.css'\r\n\r\nconst gradient = [\r\n \"rgba(0, 255, 255, 0)\",\r\n \"rgba(0, 255, 255, 1)\",\r\n \"rgba(0, 191, 255, 1)\",\r\n \"rgba(0, 127, 255, 1)\",\r\n \"rgba(0, 63, 255, 1)\",\r\n \"rgba(0, 0, 255, 1)\",\r\n \"rgba(0, 0, 223, 1)\",\r\n \"rgba(0, 0, 191, 1)\",\r\n \"rgba(0, 0, 159, 1)\",\r\n \"rgba(0, 0, 127, 1)\",\r\n \"rgba(63, 0, 91, 1)\",\r\n \"rgba(127, 0, 63, 1)\",\r\n \"rgba(191, 0, 31, 1)\",\r\n \"rgba(255, 0, 0, 1)\"\r\n ];\r\n class MapContainer extends React.Component {\r\n render() {\r\n console.log(this.props)\r\n\r\n useEffect(() => {\r\n this.props.positions\r\n }, [])\r\n return (\r\n \u003cdiv className=\"map-container\">\r\n \u003cMap\r\n google={this.props.google}\r\n zoom={this.props.zoom}\r\n initialCenter={this.props.center}\r\n >\r\n \u003cHeatMap\r\n gradient={gradient}\r\n positions={this.props.positions}\r\n opacity={1}\r\n radius={20}\r\n />\r\n \u003c/Map>\r\n\r\n \u003cdiv>{this.props.positions[0].lat}\u003c/div>\r\n\r\n \u003c/div>\r\n );\r\n }\r\n }\r\n \r\n export default GoogleApiWrapper({\r\n apiKey: \"XXX\",\r\n libraries: [\"visualization\"]\r\n })(MapContainer);\r\n```\r\n \r\n","author":{"url":"https://github.com/alikucukavci","@type":"Person","name":"alikucukavci"},"datePublished":"2021-05-06T13:40:39Z","url":"https://github.com/fullstackreact/google-maps-react/issues/513"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b45b7a3e-de7d-07b2-2069-25eac74baa86 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8982:1A1680:B8BA4F:F81AA4:6AFE6AAE |
| html-safe-nonce | b08547fbef08b080be27693a5ee76a5429fb6063b53e61f12e40e307ac04760c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTgyOjFBMTY4MDpCOEJBNEY6RjgxQUE0OjZBRkU2QUFFIiwidmlzaXRvcl9pZCI6Ijc3MjcyOTkxODcwMTE2NDQwNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bebb58c9ccdf56b9765fca40c99e9d21e80648163260e0daee0107bf71a93498 |
| hovercard-subject-tag | issue:877510842 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/fullstackreact/google-maps-react/513/issue_layout |
| twitter:image | https://opengraph.githubassets.com/90bdc2f564016c17b17168690187c9c8d967e24633f4dd6c8ba33f1d1ac6faa1/fullstackreact/google-maps-react/issues/513 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/90bdc2f564016c17b17168690187c9c8d967e24633f4dd6c8ba33f1d1ac6faa1/fullstackreact/google-maps-react/issues/513 |
| og:image:alt | Hi, I am trying to run google-map-react in my application. The idea is when I open the page with google maps it should show me a heatmap with all the data. Then I have a dropdown list where I can p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alikucukavci |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/fullstackreact/google-maps-react git https://github.com/fullstackreact/google-maps-react.git |
| octolytics-dimension-user_id | 16674738 |
| octolytics-dimension-user_login | fullstackreact |
| octolytics-dimension-repository_id | 57070925 |
| octolytics-dimension-repository_nwo | fullstackreact/google-maps-react |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 57070925 |
| octolytics-dimension-repository_network_root_nwo | fullstackreact/google-maps-react |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width