这两个标记都是通过处理polyline上的右键单击方法而放置在Google地图上的,即:
google.maps.event.addListener(polyline, 'rightclick', myMethodThatHandlesIt);问题是,我试图通过C#空间Geography.Intersects()定位点(第一个位于顶部),而且,它并不相交。
它完全取决于它的缩放。上面的一个,它是再次创建的右击(放大)的折线,是超过1公里的实际折线。
是否有任何方法可以确保标记放在行上,如在两行结束之间?

发布于 2013-10-05 18:02:44
对于其他遇到这种情况的人,我无法在Javascript中找到一种干净的方法,最终我也不需要这样做。这个制造商可能有点离谱,但我需要持久化,把它作为一个与线相交的点。因此,下面的方法已经到位,可以在存储之前更改标记位置。
我选择使用Microsoft.SqlServer.Types.SqlGeography,它的方法是
Geography.ShortestLineTo(OtherGeography)这给出了一条有两个点的新线,一个在用户的标记位置,另一个在最接近路线/polyline/linestring的交叉口。
新行的末尾是路线上与用户在polyline上单击的最接近的点。
public static System.Data.Spatial.DbGeography GetClosestPointOnRoute(System.Data.Spatial.DbGeography line, System.Data.Spatial.DbGeography point)
{
SqlGeography sqlLine = SqlGeography.Parse(line.AsText()).MakeValid(); //the linestring
SqlGeography sqlPoint = SqlGeography.Parse(point.AsText()).MakeValid(); //the point i want on the line
SqlGeography shortestLine = sqlPoint.ShortestLineTo(sqlLine); //find the shortest line from the linestring to point
//lines have a start, and an end
SqlGeography start = shortestLine.STStartPoint();
SqlGeography end = shortestLine.STEndPoint();
DbGeography newGeography = DbGeography.FromText(end.ToString(), 4326);
var distance = newGeography.Distance(line);
return newGeography;
}此外,第5887期是在谷歌网站上创建的,希望能够解决这个问题。
发布于 2013-10-04 11:08:23
由于它提供了更好的用户体验,因此标记、线条和形状的命中框略大于实际项目。所以如果你点击“关闭”,它就会计数。这对精确性没什么帮助。
对于多边形,您需要实现一个快速换行功能,以便在实际的polyline上找到关闭点。这个答案提供了一些指导:在最接近最近点的折线中找到一个点
https://stackoverflow.com/questions/19172433
复制相似问题