Virtual Earth (Bing) Pin “moves” when zoom level changes

穿精又带淫゛_ 提交于 2019-12-12 01:33:38

问题


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);

回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/2671387/virtual-earth-bing-pin-moves-when-zoom-level-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!