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

请问如何调用高德官方的 MarkerClusterer插件自定义聚合坐标样式? #57

Closed
Wphilipp opened this issue Nov 21, 2017 · 8 comments

Comments

@Wphilipp
Copy link

Wphilipp commented Nov 21, 2017

react-amap 的plugins提供的5种插件没有markClusterer,还有其他方法调用高德的这个插件吗,试过直接调用高德的api,但是如何获取高德的AMap对象?通过 events.created获取的是实例。

react-amap version

v1.1.2

OS/Browers version

chrome 53

Reproduction Link

Steps to reproduce

What is Expected?

What is actually happening?

@ioslh
Copy link
Collaborator

ioslh commented Nov 21, 2017

你好,react-amap 的 Markers 组件已经可以配置使用 AMap.MarkerClusterer 插件了 ,参考useCluster 属性的使用
另外能否简要描述一下你想使用 AMap.MarkerClusterer 实现的需求,我收集一下需求好做进一步开发。

获取高德的 AMap 对象直接 window.AMap 就可以了。

@Wphilipp
Copy link
Author

通过useCluseter好像只能使用默认样式的Clusterer,我需要自定义样式,所以尝试如下写法,但是控制台提示没有该插件
const plugins = [ { name: 'MarkerClusterer', options: { map: this.mapInstance, markers: this.markerInstance, opts: { gridSize: 50, renderCluserMarker:this._renderCluserMarker } } } ]
场景需求是 在地图上展示各个地区物联网设备的运行状态,不同故障级别的设备对应用不同的颜色的mark表示,一个地区的clusterer颜色由该地区内故障级别最高的mark的颜色表示。

@ioslh
Copy link
Collaborator

ioslh commented Nov 21, 2017

useCluster 支持传入对象配置,参考这个示例 https://jsfiddle.net/y9cv20cv/10/ 的使用。

不过你提醒了我, Markers 组件的设计不够灵活,覆盖了 Clusterer 默认的点击行为。近期会稍微升级一下以插件形式提供。

@Wphilipp
Copy link
Author

OK 谢谢大佬

@Wphilipp
Copy link
Author

Wphilipp commented Nov 22, 2017

在问一下 如何获取这个mark对象?
https://jsfiddle.net/y9cv20cv/11/

@Wphilipp Wphilipp reopened this Nov 22, 2017
@ioslh
Copy link
Collaborator

ioslh commented Nov 22, 2017

绑定 events.created 方法。参考 Markers 组件事件绑定 示例

@Wphilipp
Copy link
Author

好的,谢谢

@zuiidea
Copy link

zuiidea commented Jan 5, 2020

useCluster 使用 MarkerClustererOptions,renderClusterMarker 属性无效,可以参考这个在线例子

https://codesandbox.io/s/gaode-q6j8c

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

No branches or pull requests

3 participants