1
votes

My placemark icon, used via HREF from google mapfiles, seems to "drift" when I zoom out. In this example the placemark can make it all the way up to Norway.

It seems that Bing maps V8 doesn't support the kml which supposedly could help the icon to understand where its center is so that it would stay anchored in the map during zooming out. Additionally, the placemark is ignoring the color style. If I remove the everything between the tags and just use the default placemark from Bing, the colors and zoom work correctly. Do any of you know of a way to get this Google icon to stay anchored via KML in Bingmaps? My current workaround is simply not to use the Google icon, and instead use the default Bing maps icon, which works. Using code to do it on the bingmaps object would require too much refactoring at this time.

You can use the Bing "drag and drop" here with my code to see the problem - just paste the KML below into the "XML Panel" and click "Read XML". Then zoom out to see the placemark go traveling. If you remove the whole node, the zoom and colors work (but with the default icon). https://bingmapsv8samples.azurewebsites.net/#GeoXml%20-%20Drag%20and%20Drop

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Style id="model_normal">
    <IconStyle>
      <color>FF00FF00</color>
      <scale>1</scale>
      <Icon>
        <href>http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png</href>
      </Icon>
      <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction" />
    </IconStyle>
    <LabelStyle>
      <color>0000FF00</color>
    </LabelStyle>
    <LineStyle>
      <color>7F00FF00</color>
      <width>3</width>
    </LineStyle>
    <PolyStyle>
      <fill>1</fill>
      <color>7F00FF00</color>
    </PolyStyle>
  </Style>
  <Placemark>
    <name>Example placemark</name>
    <description></description>
    <visibility>1</visibility>
    <styleUrl>#model_normal</styleUrl>
    <MultiGeometry>
      <Point>
        <coordinates>7.003930,53.361905</coordinates>
      </Point>
    </MultiGeometry>
  </Placemark>
</kml>
1

1 Answers

3
votes

The anchor format that Bing Maps expect is in pixels, so you can update the hotSpot in IconStyle to:

<hotSpot x="32" y="32" xunits="pixels" yunits="pixels" />

By default custom pushpins on Bing Maps are anchored at bottom center - that's why the "shifting" is observed.