This is a migrated thread and some comments may be shown as answers.

Pushpins from imported KML too big and with the wrong hotspot

4 Answers 57 Views
Map
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 16 Aug 2012, 10:24 PM
Hi,

I'm using the RadMap to display KML data exported from Google Earth.  I've found that pushpins appear really large by default (about 64x64) and that it is the top left corner of the image that points to the location, and not the pin.  This looks ok when zoomed in, but it doesn't appear to point to the right location at all after you zoom out a little.

I'm loading in the elements using KmlReader.Read(Stream) and adding them to an InformationLayer.  Is this a known problem with either Google Earth or RadMap?

Thanks,

Kyle

4 Answers, 1 is accepted

Sort by
0
Kyle
Top achievements
Rank 1
answered on 16 Aug 2012, 11:37 PM
Hi,

I spent a couple more hours on this (it's very important that I get it working) and found some things out.

The default pushpin image in the KML file is, in fact, 64x64.  That explains the size.  Its hotspot is at 20, 2 pixels, i.e., 20 pixels from the left and 2 pixels from the bottom according to the reference, https://developers.google.com/kml/documentation/kmlreference#hotspot 

To check, I wrote some code to inspect the properties right after loading the KML file, and it reported the above.  I then started playing around with resetting the hotspot to different values.  I couldn't get anything to work using the expected Pixels or InsetPixels units.  Oddly, the following works:

pin.SetValue(MapLayer.HotSpotProperty,new HotSpot(){ X=20/64.0, Y=1.0-2/64.0, XUnits = HotSpotUnit.Fraction,YUnits = HotSpotUnit.Fraction});

Keeping in mind that the origin is the lower left hand corner, the code above is saying to put the HotSpot at 20 pixels from the left (expressed as a fraction), and 2 pixels from the top.  Based on what I've seen, the pixel and inset pixel hotspots seem to be broken and the fractional units are flipped vertically.  I'm puzzled as to how this wouldn't have come up before though.  All I'm trying to do is export KML from Google Earth and load it in.  

Thanks,

Kyle
0
Kyle
Top achievements
Rank 1
answered on 17 Aug 2012, 07:15 PM
Hi,

Sorry to keep posting, but I'm trying to plow through this and want to give you as much information as possible. I ended up creating my own pin image at a resolution of 32x32 with a hot spot 9 pixels from the left and 1 from the bottom.  I was able to get this to basically work by setting the hotspot to:

                    pin.SetValue(MapLayer.HotSpotProperty,
                                 new HotSpot()
                                     {X = 9, Y = -31, XUnits = HotSpotUnit.Pixels, YUnits = HotSpotUnit.Pixels});

what I think is happening is that the MapPinPoint pixel origin is the upper left (and not the lower left specified in the KML standard) and that the direction is (correctly) up.  This is why I had to use a negative offset.  This explains why loading a KML file exported from Google Earth does not work.

Note that I said that it basically works.  The pin points to the location when zoomed in, but slides off that point as you zoom out.  It would be great to get an example of a MapPinPoint that really points to the exact latitude and longitude as you zoom in and out.

I have a simple project to demonstrate the problem when loading in KML.  It's too big to put here, so I'll open up a ticket to send it.

Thanks,

Kyle 

0
Evgenia
Telerik team
answered on 21 Aug 2012, 08:03 AM
Hi Kyle,

 You have already received an answer on the same in the support thread you opened. I'm copying the answer here:
It seems that you reopened a known bug which we fixed for Q3 3011 ( as stated in the release history ). Our developers will further investigate what caused it. Meanwhile what i can suggest is that you try and change the X and Y pixels values so that the imege is positioned on the exact location.

Greetings,
Evgenia
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kyle
Top achievements
Rank 1
answered on 21 Aug 2012, 03:39 PM
Thanks for the help.  I'm able to get it working pretty well by changing the pixels.  I'll just have to remember to change it back when the new version comes out.   :)

Thanks,

Kyle
Tags
Map
Asked by
Kyle
Top achievements
Rank 1
Answers by
Kyle
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or