虚拟地球(Bing)Pin“移动”当缩放级别改变时

发布于 2024-08-29 07:32:46 字数 825 浏览 1 评论 0原文

创建了一个虚拟地球 (Bing) 地图,以在特定点显示一个简单的图钉。现在一切正常 - 图钉显示,标题和描述在悬停时弹出。

地图最初完全放大到图钉中,但奇怪的问题是,当我缩小时,它在地图上稍微移动得更低。因此,如果我从指向多伦多某处的图钉开始,如果我缩小得足够大,图钉最终会指向安大略湖的中部!如果我平移地图,图钉会正确地停留在正确的位置。当我重新放大时,它会稍微向上移动,直到回到原来的正确位置!

我已经四处寻找解决方案一段时间了,但我根本无法理解。请帮忙!!

多谢!

import with javascript: http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2

$(window).ready(function(){

    GetMap();
});

map = new VEMap('birdEye');

map.SetCredentials("hash key from Bing website");

map.LoadMap(new VELatLong(43.640144 ,-79.392593), 1 , VEMapStyle.BirdseyeHybrid, false,  VEMapMode.Mode2D, true, null);

var pin = new VEShape(VEShapeType.Pushpin, new VELatLong(43.640144 ,-79.392593));

pin.SetTitle("Goes to Title of the Pushpin");

pin.SetDescription("Goes as Description.");

map.AddShape(pin);

Created a Virtual Earth (Bing) map to show a simple pin at a particular point. Everything works right now - the pin shows up, the title and description pop up on hover.

The map is initially fully zoomed into the pin, but the STRANGE problem is that when I zoom out it moves slightly lower on the map. So if I started with the pin pointing somewhere in Toronto, if I zoom out enough the pin ends up i the middle of Lake Ontario! If I pan the map, the pin correctly stays in its proper location. When I zoom back in, it moves slightly up until it's back to its original correct position!

I've looked around for a solution for a while, but I can't understand it at all. Please help!!

Thanks a lot!

import with javascript: http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2

$(window).ready(function(){

    GetMap();
});

map = new VEMap('birdEye');

map.SetCredentials("hash key from Bing website");

map.LoadMap(new VELatLong(43.640144 ,-79.392593), 1 , VEMapStyle.BirdseyeHybrid, false,  VEMapMode.Mode2D, true, null);

var pin = new VEShape(VEShapeType.Pushpin, new VELatLong(43.640144 ,-79.392593));

pin.SetTitle("Goes to Title of the Pushpin");

pin.SetDescription("Goes as Description.");

map.AddShape(pin);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

刘备忘录 2024-09-05 07:32:46

我也有同样的问题。但是,我的代码看起来正在使用 Microsoft.Maps AJAX 方法。
我在 bing 地图上设置了事件位置,该地图是通过查询 facebook 的 api 中的 user_events 和friend_events 获得的。一个事件连同纬度和经度返回给我。
我使用这些坐标为单个引脚和集群引脚放置自定义样式的引脚。
当我缩小时,药水会移动,并且会提供有关事件位置的不切实际的表示。

答案:

我发现您必须为图钉设置“锚点”属性。

这是我发现效果很好的方法。

    var pushpinOption = {
      icon : 'images/cluster_custom.png',
      text : ''+ clusterInfo.dataIndices.length + '',
      textOffset:offset,
      anchor :  new Microsoft.Maps.Point(8, 8)
    };

资源 :
使用锚点图钉选项的示例
注意*查看“加载模块集群”
您需要单击“加载模块部分”中的第一个链接
http://www.bingmapsportal.com/isdk/ajaxv7#LoadingDynamicModule2

文档图钉选项“锚”
http://msdn.microsoft.com/en-us/library/gg427629。 ASPX

I had the same problem. However, my code looks to be using the Microsoft.Maps AJAX methods.
I set locations of events on a bing map that I got from querying facebook's api for user_events and friend_events. An event was returned to me with the latitude and longitude.
I used those coordinates to place a custom styled pin for single pins and clustered pins.
When I zoomed out the potions would move and an un-realistic representation was provided about the location of the event.

ANSWER:

I found out you have to set the "anchor" property for the pushpin.

Here is what I found that works well.

    var pushpinOption = {
      icon : 'images/cluster_custom.png',
      text : ''+ clusterInfo.dataIndices.length + '',
      textOffset:offset,
      anchor :  new Microsoft.Maps.Point(8, 8)
    };

Resources :
Example of using anchor pushpinoption
Note* Look at the "Load Module Clustering"
You will need to click the first link in the "Load modules section"
http://www.bingmapsportal.com/isdk/ajaxv7#LoadingDynamicModule2

documentat ion of pushpin option "anchor"
http://msdn.microsoft.com/en-us/library/gg427629.aspx

一桥轻雨一伞开 2024-09-05 07:32:46

不完全是您正在寻找的答案,但是,我遇到了确切的问题,发现“移动”发生在我已声明比例变换的引脚上。

  StoreEditPushPin pin = new StoreEditPushPin(Colors.Red);
  pin.Location = new Location(43.640144 ,-79.392593);
  ScaleTransform st = new ScaleTransform();
  st.ScaleX = 0.55;
  st.ScaleY = 0.55;
  pin.RenderTransform = st;
  PushPinLayer.AddChild(pin, d);

缩小时,比例因子将应用于图钉并且位置会发生移动。我会看一下您的 Pushpin 类,看看转换是否存在。

Not exactly the/an answer you're looking for but, I have the exact problem and found that the "move" happens on my pins that I have declared a scale transform for.

  StoreEditPushPin pin = new StoreEditPushPin(Colors.Red);
  pin.Location = new Location(43.640144 ,-79.392593);
  ScaleTransform st = new ScaleTransform();
  st.ScaleX = 0.55;
  st.ScaleY = 0.55;
  pin.RenderTransform = st;
  PushPinLayer.AddChild(pin, d);

When you zoom out, the scale factor is applied to the pin and the location is shifted. I would take a look at your Pushpin class to see if the transform exists.

心房敞 2024-09-05 07:32:46

尝试将 PositionOrigin 添加到图钉,将其设置为“Center”或其他。

Try adding PositionOrigin to the pushpin, set it to "Center" or whatever.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文