Insert MapPinPoint inside Ellipse

2 Answers 55 Views
Map
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Ohad asked on 13 Dec 2022, 03:13 PM

I have a MapPinPoint, and I want to insert it inside an Ellipse dynamically

How can this be done?

2 Answers, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 16 Dec 2022, 09:50 AM

Hello Ohad,

Both the Telerik MapEllipse and the native WPF Ellipse elements do not support setting elements inside of them.

Instead, what comes to my mind, would be to place the MapPinPoint instance on top of the ellipse. To do so, retrieve the location of the ellipse using the MapLayer.GetLocation method and calculate the location on which the MapPinPoint is going to be placed on top of the ellipse. Then, based on the chosen position, you could set a new location using the MapLayer.SetLocation method. Finally, to display it on the RadMap control, add it to the Items collection of the InformationLayer instance (I assume that this layer is used since the MapPinPoint element is utilized).

I have prepared a sample project for you to test regarding this inquiry.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 08 Jan 2023, 02:04 PM

First of all, thank you very much for the answer, it helped me a lot.

I have certain PinPoints that probably because their HotSpot is different, I can't put the PinPoint in the center of the Ellipse.

I have attached a KML file that creates one PinPoint, I would appreciate it if you could show me how I put the ellipse around it when the PinPoint is in the center of the circle

var hotSpot = (HotSpot)mapPinPoint.GetValue(MapLayer.HotSpotProperty);
var location = (Location)mapPinPoint.GetValue(MapLayer.LocationProperty);
MapLayer.SetLocation(ellipse, location);
MapLayer.SetHotSpot(ellipse, hotSpot);

And it doesn't work well for the PinPoint I attached here

This is my code right now

Stenly
Telerik team
commented on 11 Jan 2023, 03:26 PM

Hello Ohad,


To achieve this, you could calculate the Location of the Ellipse element when using the MapLayer.SetLocation method. The Location instance that will be returned for the MapPinPoint element could be used to calculate this location.

The following code snippet shows a sample implementation of this suggestion:
var pinPointLocation = (Location)mapPinPoint.GetValue(MapLayer.LocationProperty);
MapLayer.SetLocation(ellipse, new Location(pinPointLocation.Latitude + 6, pinPointLocation.Longitude - 11));

The produced result is as follows:

However, the location of the Ellipse would have to be manually recalculated each time a zoom is performed, in order for the MapPinPoint element to appear in its center. Each time a zoom is performed, the ZoomChanged event occurs, which could be utilized when implementing this functionality. In addition, I think that the Zoom article of the RadMap control's documentation could be useful when implementing this functionality.

Tags
Map
Asked by
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Stenly
Telerik team
Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or