
@H_301_8@
> Google Map Javascript API https://developers.google.com/maps/documentation/javascript/geometry#isLocationOnEdge.
> AndroID示例https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/PolyUtil.java
>我为gmaps google maps API for C#找到了一个c#库,但它不支持isLocationOnEdge函数@H_301_8@
有没有办法在c#中执行上面的要求?@H_301_8@解决方法 以下是IsLocationOnEdge For C#的实现.
@H_301_8@
@H_301_8@
using System;using System.Collections.Generic;using System.Device.Location;using System.linq;using System.Text;using System.Text.RegularExpressions;using System.Threading;using System.Threading.Tasks;namespace TestConsoleApp{ class Program { static voID Main(string[] args) { var path = new List<Location> { new Location(1,1),new Location(2,2),new Location(3,3),}; var point = new Location(1.9,1.5); bool isOnEdge = isLocationOnEdge(path,point); Console.ReadKey(); } static bool isLocationOnEdge(List<Location> path,Location point,int tolerance = 2) { var C = new GeoCoordinate(point.Lat,point.Lng); for (int i = 0; i < path.Count - 1; i++) { var A = new GeoCoordinate(path[i].Lat,path[i].Lng); var B = new GeoCoordinate(path[i + 1].Lat,path[i + 1].Lng); if (Math.Round(A.Getdistanceto(C) + B.Getdistanceto(C),tolerance) == Math.Round(A.Getdistanceto(B),tolerance)) { return true; } } return false; } } class Location { public Location(double Lat,double Lng) { this.Lat = Lat; this.Lng = Lng; } public double Lat { get; set; } public double Lng { get; set; } }} 参考文献:@H_301_8@
Check is a point (x,y) is between two points drawn on a straight line
Calculating Distance between two Latitude and Longitude GeoCoordinates@H_301_8@ 总结
以上是内存溢出为你收集整理的C#中的Google几何Api全部内容,希望文章能够帮你解决C#中的Google几何Api所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)