Gmap.Net标记在不正确的位置,但是当地图缩放标记去正确的地方 [英] Gmap.Net Marker at incorrect position but when the map is zoomed the marker goes to right place

查看:948
本文介绍了Gmap.Net标记在不正确的位置,但是当地图缩放标记去正确的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows窗体应用程序 Gmap.Net 控制器,我想要做的是基于位置提供了一个外部资源添加标记。问题是,当我添加标记最初是在不正确的位置绘制的,但之后,我缩小它去正确的地方。所以这是我走到这一步:

I've a Windows Forms Application with a Gmap.Net controller, what I want to do is to add markers based on an outside sources that provides locations. The thing is that when I add a marker is initially drawn in an incorrect location, but after I zoom out it goes to the right place. So this is what I got so far:

我的地图控制器宣布将设在巴拿马

My Map controller is declare to be located at Panama, Panama.

private void button2_Click(object sender, EventArgs e)
{    
    //Layer count is just a variable to add new OverLays with different names
    var markersOverlay = new GMapOverlay("markers" + layerCount);

    //Marker far away in Quebec, Canada just to check my point in discussion        
    var marker = new GMarkerGoogle(new PointLatLng(58.0032, -79.4957), GMarkerGoogleType.red_small);

    markersOverlay.Markers.Add(marker);
    gmap.Overlays.Add(markersOverlay);
    layerCount++;
}



所以,当我按下按钮,我得到了什么是这样(有记地图上的位置将它设置为在巴拿马和加拿大标记):

So when I press the button what I got is this (have in mind that the map location it's set to be in Panama and the marker in Canada):

当我缩小,标记去加拿大正确的位置

And when I zoom out, the marker goes to the correct position in Canada.

为什么我的标记是在巴拿马已制订初步

Why my marker is been drawn in Panama initially?

PD :我已经检查了这<一个HREF =http://stackoverflow.com/questions/30636745/gmap-marker-is-placed-in-wrong-position>问题而是因为我需要增加更多的它不能解决我的问题大于1的标记和 myMap.UpdateMarkerLocalPosition(标记)不是我一个解决方案。

P.D: I already check this question but it doesn't resolve my problem because I need to be adding more than 1 marker and myMap.UpdateMarkerLocalPosition(marker) is not a solution for me.

推荐答案

我想这是因为你要添加的标记尚未添加到地图的覆盖重叠。尝试切换语句的顺序如下:

I think it's because you're adding the marker to the overlay that has not been added to the map's overlays. Try to switch the order of the statements as follows:

gmap.Overlays.Add(markersOverlay);
markersOverlay.Markers.Add(marker);



为我工作。

Worked for me.

这篇关于Gmap.Net标记在不正确的位置,但是当地图缩放标记去正确的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆