Hi,
I have a standard forms map. This map is stored inside of an absolute view like this
var absMap = new AbsoluteLayout
{
HeightRequest = App.ScreenSize.Height * .35,
WidthRequest = App.ScreenSize.Width,
};
map = new Map(new MapSpan(new Position(App.Self.Configuration.Latitude, App.Self.Configuration.Longitude),
zoom, zoom))
{
HasZoomEnabled = true,
HasScrollEnabled = true,
HeightRequest = App.ScreenSize.Height * .35,
WidthRequest = App.ScreenSize.Width,
MapType = MapType.Hybrid,
IsShowingUser = true,
};
absMap.Children.Add(map);
I then create an image an place that onto the map which is dead centre.
var imgPin = new Image
{
Source = "pinned_location.png",
HeightRequest = 30,
WidthRequest = 30,
};
var mapXMidPos = (App.ScreenSize.Width / 2) - (imgPin.WidthRequest / 2);
var mapYMidPos = (absMap.HeightRequest / 2) - (imgPin.HeightRequest);
absMap.Children.Add(new AbsoluteLayout
{
Padding = new Thickness(mapXMidPos, mapYMidPos, 0, 0),
Children = { imgPin }
});
This is fine and works OK.
I now create another image and add it to the map
var imgPointer = new Image
{
Source = "mylocation.png",
WidthRequest = 30,
HeightRequest = 30,
};
var tapPointer = new TapGestureRecognizer
{
NumberOfTapsRequired = 1,
Command = new Command(() =>
{
if (!SettingsManager.LocationState)
DisplayAlert(LangResources.NoLocationMoveErrorTitle, LangResources.NoLocationMoveErrorMessage, LangResources.OK);
else
map.MoveToRegion(MapSpan.FromCenterAndRadius(
new Position(myCoords.latitude, myCoords.longitude), Distance.FromMiles(.05)));
})
};
imgPointer.GestureRecognizers.Add(tapPointer);
var aPointer = new AbsoluteLayout
{
Padding = new Thickness(App.ScreenSize.Width - 40, absMap.HeightRequest - 70, 0, 0),
Children = { imgPointer }
};
absMap.Children.Add(aPointer);
Again, works fine - the only issue is that once I've added this second image, the map no longer moves around on the phone (it does though on the simulator but only if the absMap.HeightRequest - 70 is a number less that 75 - so 74 is fine).
I'm at a loss as to why the map doesn't move sometimes but does other times and why it only moves on the simulator and not my 6+.
Any ideas, clues or insights into why this should happen or better still, how the blooming heck to fix it?
The absMap and the rest of the screen UI is held in a StackLayout for rendering.
Thanks
PFJ