我在 Xamarin Android 和 iOS 上使用 Google map
我试图从随机点击坐标创建一个封闭的多边形。
Android 喜欢:
var options = new PolygonOptions();
options.InvokeFillColor(int.Parse("80000000", System.Globalization.NumberStyles.HexNumber));
options.InvokeStrokeColor(int.Parse("000000", System.Globalization.NumberStyles.HexNumber));
options.InvokeStrokeWidth(2);
options.AddAll(listOfPosition); //list of tapped coordinates
googleMap.AddPolygon(options);
iOS 喜欢:
var polygon = new Polygon();
polygon.Path = path; // this is my list of tapped coordinates
polygon.StrokeWidth = 2;
polygon.StrokeColor = UIColor.Black;
polygon.FillColor = UIColor.FromRGBA(0, 0, 0, 0.3f);
polygon.Map = mapView;
假设我像这样随机点击了坐标:
Debug|LOCATION:: 37.9115841998119 : -122.566957734525
Debug|LOCATION:: 37.9117754470967 : -122.561504803598
Debug|LOCATION:: 37.9085008969633 : -122.566276118159
Debug|LOCATION:: 37.9086561762004 : -122.562640719116
Debug|LOCATION:: 37.9102216477146 : -122.561550065875
Debug|LOCATION:: 37.9098513127501 : -122.567805983126
Debug|LOCATION:: 37.9123967989511 : -122.564518935978
我怎样才能使它关闭多边形而不在内部相交线甚至可能点击坐标达到 100 个位置数据。?任何想法或计算?提前致谢..
最佳答案
您不必在本地计算,使用 Google map 的 Shapes API
- > https://developer.xamarin.com/guides/android/platform_features/maps_and_location/maps/part_2_-_maps_api/#Drawing_on_the_Map
- > https://developers.google.com/maps/documentation/android-api/shapes
对封闭多边形的点进行局部排序
关于android - 谷歌地图 Android 和 iOS Xamarin : Create Close Polygon on random tapped coordinates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45227207/