简体   繁体   English

react-google-charts 标记 GeoChart 标记不起作用

[英]react-google-charts Marker GeoChart markers not functional

I have been trying to use the <Chart /> react component from the react-google-charts API, however, I can't seem to get the markers to show up on the map.我一直在尝试使用react-google-charts API 中的<Chart /> react 组件,但是,我似乎无法让标记显示在地图上。

I noticed that even the examples of Marker GeoCharts on the React Google Charts site do not have functional markers.我注意到,即使是React Google Charts站点上的 Marker GeoCharts 示例也没有功能标记。

Here is a code snippet from the site:这是该网站的代码片段:

 <Chart width={'500px'} height={'300px'} chartType="GeoChart" data={[ ['City', 'Population', 'Area'], ['Rome', 2761477, 1285.31], ['Milan', 1324110, 181.76], ['Naples', 959574, 117.27], ]} options={{ region: 'IT', displayMode: 'markers', colorAxis: { colors: ['green', 'blue'] }, }} // Note: you will need to get a mapsApiKey for your project. // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings mapsApiKey="YOUR_KEY_HERE" rootProps={{ 'data-testid': '2' }} />

Here's a screenshot of the output:这是输出的屏幕截图:标记 GeoChart 输出(意大利)

I also generated my own API key, and I have also tried using the "columns" prop in the Chart component.我还生成了自己的 API 密钥,并且还尝试在图表组件中使用“列”道具。 I still can't seem to get the markers to work.我似乎仍然无法让标记起作用。

Even if you do not know how to solve this error, if you have any recommendations for interactive maps that can be used with react (and that I can add interactive markers to), please let me know!即使您不知道如何解决这个错误,如果您对可与 react 一起使用的交互式地图有任何建议(我可以添加交互式标记),请告诉我!

您必须启用 Geolocation API 和 Geocoding API 才能使标记工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM