Map loosing position on orientation change on Xamarin iOS - ios

I have a custom map in xamarin that i have custom renders in both iOS and Android.
The problem is in iOS when i navigate to a position and then rotate my device to landscape it moves my map center to what I think is lat 0, lon 0
Even if i set my map location when the map is first rendered it resets as soon as the orientation changes.
I use the following code to set the camera position
MKMapCamera cam = new MKMapCamera();
CLLocationCoordinate2D MyPosition;
MyPosition = Constants.centreLatLng
cam.Altitude = 1500;
cam.CenterCoordinate = MyPosition;
Constants.nativeMap.SetCamera(cam, false);
I want it so when i change the orientation my map center stays the same as what it was.

As you can see in the Xamarin official documentation for the MapKit,
https://learn.microsoft.com/en-us/dotnet/api/mapkit.mkmapcamera?view=xamarin-ios-sdk-12 you can try to over ride the DidChange or DidChangeValue function and figure out what the latest value of the camera position is. So then you know what value to set OnSizeAllocated.
Also you might want to try initializing the values of the map shown in the example, because you shouldn't be having this problem.

Related

Here Map SDK IOS (Premium) tap on the marker

Good afternoon, who once worked with heremap sdk premium for ios. How do I make it possible to click on the NMAMapMarker? What they have written in the documentation does not describe it, but maybe I'm wrong.
there are different option available for NMAMapMarker to use.
This represents a marker used to display an icon on a geographical position on a map. The map handles proper placement of icons on the screen as well as panning and rotation.
+mapMarkerWithGeoCoordinates:
+mapMarkerWithGeoCoordinates:icon:
+mapMarkerWithGeoCoordinates:image:
coordinates
icon
draggable
draggingOffsetEnabled
anchorOffset
-initWithGeoCoordinates:
-initWithGeoCoordinates:icon:
-initWithGeoCoordinates:image:
-setAnchorOffsetUsingLayoutPosition:
-setSize:forZoomLevel:
-setSize:forZoomRange:
-resetIconSize
Check for more details : https://developer.here.com/documentation/ios-premium/3.18/api_reference_jazzy/Classes/NMAMapMarker.html#%2Fc:objc(cs)NMAMapMarker(im)initWithGeoCoordinates.
Please revert with your code implementation in case of any further concern.

MKMapView in satellite mode displays black screen while zooming

This problem occurs only in satellite map. Is there a fix to avoid displaying this black screen?
Note: Apple Map application not displaying this black screen in device But MKMapView displaying this black screen.
Set zoomlevel of mapView to maximum zoom level 18 as MKMapView didn't have predefine zoomlevel set so we have to set it manually using MKCoordinateSpan
About zoomlevel you will get help by this link http://troybrant.net/blog/2010/01/mkmapview-and-zoom-levels-a-visual-guide/

How to hide circular compass icon on MKMapview in iOS

I want to hide the circular compass icon on MKMapview which appears when a user rotates the map. I have attached a screen shot for reference. I don't want to display the circular compass icon but I do want to allow rotation on the map.
Starting in iOS 9 you can finally hide the compass in MKMapView.
mapView.showsCompass = NO;
If you're not rotating the map programatically and it hasn't already been rotated, disable rotation entirely, using
mapView.rotateEnabled = NO;
The compass only shows up when the map is rotated, so by doing this you ensure that the compass is never triggered.
The current iOS maps does not have the option to turn off the compass.
MapKit Class in the apple documentation also does not carry any information about a compass setting as either a property or creation only setting.
Without restriction on rotation you need to try with the solution given at following url:
http://jdkuzma.tumblr.com/post/79294999487/xcode-mapview-offsetting-the-compass-and-legal
You can either try it by setting its layout margin:
By moving a little bit lower:
[self.mapView setLayoutMargins:UIEdgeInsetsMake(20, 0, 20, 0)];
or moving it up a little bit higher:
[self.mapView setLayoutMargins:UIEdgeInsetsMake(-50, 0, -50, 0)];
Hope this might get you what you need.

How to set MKMapView view angle and turn off 3D building?

I am currently working on a navigation app. Is there a way to set view angle in MapKit? I know Google Map iOS SDK has it as one of parameter in viewing camera that you could set, but I wasn't able to find it in MapKit.
Also is there a bool value to turn off 3D building? They are kind of annoying for a navigation app.
Thanks in advance!
Add in viewDidLoad or viewWillAppear:
self.mapView.pitchEnabled = YES;
self.mapView.pitchEnabled = NO;
self.mapView.showsBuildings = false
(swift code) Turns off buildings.
Swift 4
mapView.settings.tiltGestures = false
Use pitch to provide viewing angle. For example, mapview.pitch or mapview.camera.pitch depending on whether you are using a camera or not. Also, set showsbuildng to NO.

BlackBerry RichMapField is blank on device

I use RichMapField like below to display Blackberry Maps in my application.
RichMapField map = MapFactory.getInstance().generateRichMapField();
add(map);
The map is displayed properly on the BlackBerry simulator, but on a device the map field is blank.
Edited:
This is some part of my code. The code given below adds 2 markers to the map, which works perfectly fine, but the only problem is i don't see the map.
MapLocation Location1 = new MapLocation(coordinates[0],coordinates[1],"Location 1",null);
int Location1ID = data.add((Mappable)Location1,"Location 1");
data.tag(Location1ID, "Location1");
MapLocation Location2 = new MapLocation(coordinates[0]-0.00009,coordinates[1]- 0.00009,"Location 2",null);
int Location2ID = data.add((Mappable)Location2,"Location 2");
data.tag(Location2ID, "Location2");
data.setVisible("Location");
map.getMapField().update(true)
Add the following:
map.getAction().setCentreLatLon(coordinates[0],coordinates[1]);
map.getAction().setZoom(0);
I think this way you will see the map now. For some reason I'm still investigating, the map.getAction().update(true);
isn't working well for me too.
depends on your screen painting method. If your override your screen in such a way that u repaint ur screen on top of ur map, you obviously cant see the map.
Can you try pasting more code and ur paint method. It will help.

Resources