In my code, I specify the GeoBoundsNW corner of the tile to be (45.43, -75.77) & GeoBoundsSE corner to be (45.35,-75.67). The dimensions of the image are 360 x 252 pixels.
When I run my application, I place my cursor at the NW corner of the tile. The MouseLocationIndicator says 45 24' 52" N, 75, 46' 12" W which expressed in decimal degrees is 45.41, -75.77. This is close, but slightly different from what I expected to see, because I specified GeoBoundsNW = (45.43, -75.77).
How do I get the custom tile to show on the map at the correct NW position?
Here is my code:
private
void
AddCustomTileProvider()
{
UriImageProvider CustomProvider =
new
UriImageProvider
{
Uri =
new
Uri(
"my_image_path.png"
, UriKind.RelativeOrAbsolute),
GeoBoundsNW =
new
Location(45.43, -75.77),
GeoBoundsSE =
new
Location(45.35,-75.67),
Opacity = 0.7
};
this
.radMap.Providers.Add(CustomProvider);
MapLayer.SetZoomRange(CustomProvider,
new
ZoomRange(1, 15));
}
9 Answers, 1 is accepted
We are not able to reproduce the issue on our local tests with the latest version of RadMap conrol. I tried to reproduce it with the following code:
<
StackPanel
>
<
telerik:MapMouseLocationIndicator
MapControl
=
"{Binding ElementName=radMap}"
LocationFormat
=
"Number"
Margin
=
"10"
HorizontalAlignment
=
"Center"
Width
=
"250"
FontSize
=
"12"
IndicatorLabelBackground
=
"White"
IndicatorLabelBorderBrush
=
"Black"
Foreground
=
"Black"
/>
<
telerik:RadMap
Name
=
"radMap"
Width
=
"600"
Height
=
"480"
MouseLocationIndicatorVisibility
=
"Visible"
ZoomLevel
=
"10"
Center
=
"36.5,-109.5"
GeoBoundsNW
=
"37,-110"
GeoBoundsSE
=
"36.5,-109.5"
>
<
telerik:RadMap.Provider
>
<
telerik:OpenStreetMapProvider
/>
</
telerik:RadMap.Provider
>
<
telerik:InformationLayer
x:Name
=
"informationLayer"
>
<
telerik:MapPolygon
x:Name
=
"myPolygon"
Points
=
"37,-110 37,-109.5 36.5,-109.5 36.5,-110"
Stroke
=
"Red"
StrokeThickness
=
"4"
/>
</
telerik:InformationLayer
>
</
telerik:RadMap
>
</
StackPanel
>
The image attached is the result where the mouse cursor is positioned over the Top Left edge of the Rectangle (the Northwest point). You may see that the geobounds are correctly displayed.
Best wishes,
Evgenia
the Telerik team
Telerik Team,
In your answer, I do not see an answer related to the UriImageProvider.
I also have the problem with bad positioning of image on map.
Using these coordinates:
var uriImageProvider = new UriImageProvider();
uriImageProvider.GeoBoundsNW = new Telerik.Windows.Controls.Map.Location() { Latitude = 70, Longitude = -33 };
uriImageProvider.GeoBoundsSE = new Telerik.Windows.Controls.Map.Location() { Latitude = -44, Longitude = 70 };
The image will be projected, somewhere around N66
I am using the latest version 2011.2.1040 internal build. The official 2011.2 release has the same problem.
The size of the image you show using UriImageProvider must have the same pixel size as the region set by GeoBounds for the current zoom level. Otherwise it will not be positioned properly.
All the best,
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Sorry, but I do not understand your answer.
'must have the same pixel size as the region set by GeoBounds for the current zoom level'
Do you mean I have to generate different sized images, depending on the zoom level?
How can I know the pixel size?
What i want to achive is this: I have an image with size x and y , which represents a nw-se rect.
How do I overlay this on the map? Of course at the correct position:)
Could you explain it a bit more? Thank you.
Best regards, Henri
Yes, you have to generate images of different size, depending on the zoom level.
The pixel size of the geographical region depends on the zoom level and projection you are using. You can use following code to calculate pixel size of the region for default (Mercator) projection:
<
telerik:RadMap
Name
=
"radMap"
>
<
telerik:RadMap.Providers
>
<
telerik:EmptyProvider
/>
</
telerik:RadMap.Providers
>
</
telerik:RadMap
>
this
.radMap.ZoomLevel = 6;
LocationRect rect =
new
LocationRect(
new
Location(40, 50),
new
Location(30, 70));
rect.MapControl =
this
.radMap;
Size pixelSize =
this
.radMap.GetPixelSize(rect.Center, rect.Width, rect.Height);
All the best,
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
I have used your example to 'GetPixelSize' but it is unclear exactly what this is returning, can you explain what the 'Size' represents?
In my scenario the user draws a rectangle on the map and uploads a custom image which represents the 'map' that covers that region.
Then they are able to later on, use the map control to add items inside their defined area. In this case, the image needs to fit the visible map area which needs to sit exactly in the region they have defined.
Note, the same image is used for all zoom levels.
I understand the image needs to be the correct size but I am trying to understand how to resize the image using a combination of the current zoom level and the rectangle size/geobounds that he/she has put on the map surface.
I don't need code to resize the bitmap, I can do that, but I do need to know how to extract the size the image should be from the various informatinon available to me at runtime.
e.g. pseudocode
ResizeImage( int iZoomLevel, RadMapRectangle Rectangle)
{
UriImageProvider_ImageWidth = CalcWidth() <-- based on iZoomlevel and Rectangle properties, how?
UriImageProvider_ImageHeight = CalcHeight() <-- based on iZoomlevel and Rectangle properties, how?
UriImageProvider_iImageResolution = CalcRes() <- important?
ResizeImage( UriImageProvider_ImageWidth, UriImageProvider_ImageHeight, UriImageProvider_iImageResolution )
UriProviderGeobounds = somecalc()
}
Can you help? How do I calculate the correct image dimensions on the fly? I have searched the manual and forums extensivly but can't fathom out how to make these calculations. Can someone point me in the right direction?
Many thanks
Mark.
:-)
Mark.
The 'Size' represents the size in pixels of the LocationRect structure for the current zoom level of RadMap. The LocationRect represents the rectangular region on the map. In fact it is the UriProviderGeobounds in your scenario. When the user uploads a custom image then the drawn rectangle represents the geo bounds (LocationRect) where the image should be placed. Each map shape (also MapRectangle) contains the GeographicalBounds property which has the LocationRect type and represents the geo bounds of the figure. So, you can use it to calculate its size in pixels for current zoom level which will be used for the uploaded image.
Best wishes,
Andrey Murzov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you very much for your reply and detailed information given. I will investigate this during the week and provide feedback for you.
Regards
Mark.