gpt4 book ai didi

google-earth - Google Earth API 移动多边形

转载 作者:行者123 更新时间:2023-12-04 16:47:49 26 4
gpt4 key购买 nike

我刚刚开始使用 .Net 的 GEPlugin 控件使用 Google Earth 进行编码,但仍有很多东西要学习。

让我感到困惑的是当我尝试拖动多边形时。

每当 mousemove 事件触发时调用下面的方法,并且应该移动多边形的每个点,同时保留多边形的原始形状。每个点的经纬度都会改变,但多边形不会在 map 上移动位置。

移动多边形中的一个点会导致它重绘,我是否需要调用一个方法来强制重绘或者完全做其他事情?

谢谢!

private void DoMouseMove(IKmlMouseEvent mouseEvent)
{
if (isDragging)
{
mouseEvent.preventDefault();

var placemark = mouseEvent.getTarget() as IKmlPlacemark;

if (placemark == null)
{
return;
}

IKmlPolygon polygon = placemark.getGeometry() as IKmlPolygon;


if (polygon != null)
{
float latOffset = startLatLong.Latitude - mouseEvent.getLatitude();
float longOffset = startLatLong.Longitude - mouseEvent.getLongitude();

KmlLinearRingCoClass outer = polygon.getOuterBoundary();
KmlCoordArrayCoClass coordsArray = outer.getCoordinates();

for(int i = 0; i < coordsArray.getLength(); i++)
{
KmlCoordCoClass currentPoint = coordsArray.get(i);
currentPoint.setLatLngAlt(currentPoint.getLatitude() + latOffset,
currentPoint.getLongitude() + longOffset, 0);
}
}
}
}

最佳答案

关于google-earth - Google Earth API 移动多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2975614/

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