This is a migrated thread and some comments may be shown as answers.
Drawing Shapes in Information Layer
3 Answers 122 Views
Map
This is a migrated thread and some comments may be shown as answers.
Joshua Ault
Top achievements
Rank 1
Joshua Ault asked on 06 May 2010, 06:05 PM
Hello:

I am drawing a MapEllipse in an information layer. The Ellipse will appear at different locations based on where the user clicks. The problem I am having is the MapEllipse positions itself based on its top left corner. I need to position based on its center. How can I do this? Are there any examples for this kind of scenario?

I set up one location to work with the centering, but when you click on another location the ellipse was not set to the center anymore. The ellipse needs to be able to center on different locations and it will be a different size ellipse at different zoom levels.

Any thoughts or suggestions would be great.

Thank You.

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 10 May 2010, 08:08 AM
Hi Joshua Ault,

The size of the MapEllipse is given in the kilomiters or miles depends on the DistanceUnit set for the RadMap control. You can convert metric size to the degree size using GetLatitudeLongitudeSize method of the RadMap control. Then you should set ellipse location so it will be shifted to the half of the degree size. As result you will have ellipse with center at the specified location. For example, following code add ellipse with center at the point of the mouse click:

private void RadMapMapMouseClick(object sender, MapMouseRoutedEventArgs eventArgs)
{
    double ellipseWidth = 3; // 3 kilomiters
    double ellipseHeight = 3; // 3 kilomiters
  
    // Calculate ellipse size in degrees (latitude-longitude).
    Size degreeSize = this.radMap.GetLatitudeLongitudeSize(eventArgs.Location, ellipseWidth, ellipseHeight);
  
    // Calculate new ellipse location. 
    // Shift from click-point on half of the ellipse size in degrees.
    Location ellipseLocation = new Location(
        eventArgs.Location.Latitude + degreeSize.Height / 2,
        eventArgs.Location.Longitude - degreeSize.Width / 2);
  
    MapEllipse ellipse = new MapEllipse()
    {
        Location = ellipseLocation,
        Width = ellipseWidth,
        Height = ellipseHeight,
        Fill = new SolidColorBrush(Color.FromArgb(128,0,255,0))
    };
  
    this.informationLayer.Items.Add(ellipse);
}


Sincerely yours,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Joshua Ault
Top achievements
Rank 1
answered on 11 May 2010, 04:24 PM
Hello:

I have implemented the new code that you supplied. It was a huge improvement and worked 50% better than what I had. However, as I begin to zoom out from the map the shape begins to be off center. This starts around zoom level 10 and on. Do you know what could be causing this? When I am zoomed into the map the shape stays centered.

Thank You.
0
Andrey
Telerik team
answered on 12 May 2010, 07:18 AM
Hi Joshua Ault,

I'm sorry, I can't reproduce it using the map providers which are shipped with RadMap control (Bing and Open Street). When I put the ellipse with center at the specific point (center of the city, for example) and zoom-in/out it stay over this point regardless of the zoom level (from 1 to 19). The center of the ellipse isn't shifted. Could you, please, clarify what map provider do you use and how can we reproduce the behavior?

Best wishes,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Map
Asked by
Joshua Ault
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Joshua Ault
Top achievements
Rank 1
Share this question
or