gpt4 book ai didi

c# - 基于聚类点计数的颜色聚类特征

转载 作者:行者123 更新时间:2023-11-28 13:37:52 25 4
gpt4 key购买 nike

我正在使用 Xamarin.iOS 和 Mapbox iOS SDK(Naxam.Mapbox.iOS NuGet 包 here 开发应用程序。我在 MapBox iOS SDK 网站上关注这个例子:https://docs.mapbox.com/ios/maps/examples/clustering/ .

我在将这部分代码转换为 C# 时遇到问题:

// Color clustered features based on clustered point counts.
let stops = [
20: UIColor.lightGray,
50: UIColor.orange,
100: UIColor.red,
200: UIColor.purple
]

和:

circlesLayer.circleColor = NSExpression(format: "mgl_step:from:stops:(point_count, %@, %@)", UIColor.lightGray, stops)

如果我这样做,我可以为集群设置一个独特的颜色:

circlesLayer.CircleColor = NSExpression.FromConstant(FromObject(UIColor.Green));

但如果我按照示例进行操作,我将无法做到这一点,在该示例中,表达式格式采用 3 个参数:stringUiColorArray

但在 C# NSExpression.FromConstant 中,最多接受 2 个参数:string 和一个 NSObject[],所以我创建了这个:(以匹配示例中的数组“stops”)

NSDictionary[] stops = new NSDictionary[]
{
new NSDictionary(new NSNumber(0), FromObject(UIColor.Green)),
new NSDictionary(new NSNumber(20), FromObject(UIColor.Blue)),
new NSDictionary(new NSNumber(100), FromObject(UIColor.Red))
};

但是没有成功,我应该怎么做呢?

最佳答案

它应该是一个 nsfloat 而不是一个整数,所以像这样定义第一个参数:

new NSNumber(0f)

关于c# - 基于聚类点计数的颜色聚类特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56394241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com