IsShowingUser not working in Xamarin Forms - visual-studio-2013

i'm developing an app based on maps.
Here my problem is i'm not able to display user location on maps. but i can able to displaying the map's using Xamarin.Forms.
Here is my Code
var map = new Map(
MapSpan.FromCenterAndRadius(
new Position(17.3660, 78.4760), Distance.FromMiles(0.3)))
{
IsShowingUser = true,
HeightRequest = 100,
WidthRequest = 960,
VerticalOptions = LayoutOptions.FillAndExpand
};
var stack = new StackLayout { Spacing = 0 };
stack.Children.Add(map);
Content = stack;
My out put
here i want to display the user current location.
this entire code was return in Xamarin Shared code.
i'm not using Xamarin Android.
can any one help me to solve this problem.
Thanks in advance.

Most platforms require you to request permission to get a users location via GPS.
For Android this is located in the Android Manifest (under project properties). Check both ACCESS_FINE_LOCATION and ACCESS_COURSE_LOCATION.

It's a known bug on Android. It's working fine on iOS.
Here's the link to the bug report on bugzilla.
A possible workaround would be to show a map pin instead for as long as the bug hasn't been fixed. It goes like this:
map.Pins.Add(new Pin { Label = "You are here",
Position = new Position(17.3660, 78.4760) });
UPDATE: This issue has been fixed on Xamarin.Forms.Maps version 1.3.0.6292.

Related

Xamarin.Android Camera2 API Camera don`t appears in default apps

I downloaded the sample Сamera2 API code to my device. In another app, I want to launch a third-party camera, but I can't select the one I downloaded.
I Found solution for Xamarin.Android. I added above my CameraActivity page right near that Manifest String
[Activity (Label = "Camera2Basic", MainLauncher = true, Icon = "#drawable/icon")]
my Intent Filter which contains this code
[IntentFilter(new[] { "android.media.action.IMAGE_CAPTURE" },
Categories = new[] { Intent.CategoryDefault})]
This code write strings in Manifest, they needs for default intent call

BarTintColor does not work with PrefersLargeTitles in iOS 13 in Xamarin

As I am trying to prepare our app for iOS 13, I am running into a rendering issue I can not fix.
We have code like this in our ViewDidLoad:
this.NavigationController.SetNavigationBarHidden(false, false);
this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB(3, 117, 178);
this.NavigationController.NavigationBar.TintColor = UIColor.White;
this.NavigationController.NavigationBar.Translucent = false;
this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.White
};
View.BackgroundColor = UIColor.White;
this.NavigationController.NavigationBar.PrefersLargeTitles = true;
this.NavigationController.NavigationBar.LargeTitleTextAttributes = new UIStringAttributes
{
ForegroundColor = UIColor.White
};
In iOS 12, it looks like this
Just compiling for 13, it now looks like
But if I scroll, it does look right (except for search)
We got a lot of this information previously from the dev blogs https://devblogs.microsoft.com/xamarin/go-large-ios-11/, and I tried several iterations there. I even tried putting part of this in our AppDelegate too.
I can change the text (Its actually working here, thats why you see nothing). It works fine on a page without PrefersLargeTitles set.
This was a bug in Xamarin before 12.99.3.5.
In 12.99.3.5, the new ScrollEdgeAppearance property was available, but also did not work.
This is fixed in 12.99.4.1 and later.
Progress can be tracked at https://github.com/xamarin/xamarin-macios/issues/6834

Adding a new view on top in NativeScript

Anyone got a tip how to add a View over the current view (modal)? I'm creating an app with a video recorder, and the video screen is presented modally on the screen. I want some text to show up above the video modal, and I think I've tried any approach I can think of atm.
Currently im stuck with something like:
var topMost = frameModule.topmost();
var View = new ViewModule.View(questionHolder);
topMost.currentPage._addView(View, 0);
But with no success. questionHolder is a view I fetch with
currentpage.getViewById
Edit:
From the answer of #davecoffin where I understood you could not mix native views and nativescripts views, I was able to solve this in my case by accessing the native view directly and adding a subview to it. In my case:
var sharedApplication = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
var overlay = UIView.alloc().initWithFrame({
origin : {
x: 0,
y: 44,
},
size: {
height: 100,
width: platform.screen.mainScreen.widthPixels
}
});
overlay.backgroundColor = UIColor.blackColor;
overlay.alpha = .6;
sharedApplication.keyWindow.rootViewController.presentedViewController.cameraOverlayView = overlay;
You can directly create and use modal pages as described in this article.
If I am understanding your approach correctly...
You cant add Nativescript views on top of native views.
Check out this forum question: https://discourse.nativescript.org/t/appending-nativescript-views-to-a-native-ui-view/1412
Basically once you have appended a native view (not a nativescript layout or ui view), then every view you append after that must be a native view. For iOS you use addSubview, not sure about android atm.

After updating xamarin forms, stacklayouts inside relativelayouts are not laying out properly

Some of my StackLayouts are wrapping to their content width/height rather than using the constraints given to them when adding them to a RelativeLayout. An example of this happening is my navigation bar. I create it like this
var leftButtonLayout = new StackLayout
{
Children = { _sceneMainToolsView.MenuButton, _sceneTitle },
Orientation = StackOrientation.Horizontal,
BackgroundColor = Color.FromHex(Colours.Orange),
HorizontalOptions = LayoutOptions.StartAndExpand,
Spacing = 8
};
I add it to my relative layout
_layout.Children.Add(leftButtonLayout,
Constraint.RelativeToParent(p => 0),
Constraint.RelativeToParent(p => 0),
Constraint.RelativeToParent(p => p.Width),
Constraint.RelativeToParent(p => NavBarHeight));
And later I set my ContentView's Content Property
Content = _layout;
This has been happening since I updated my xamarin forms nuget package to 2.3.0.49 (necessary to use certain dll's). Does anybody know why this is happening or how to fix it? I'm testing on Android 4.4.2 (kitkat) and compiling using 6.0 (marshmallow).

Can we generate QR code through Xamarin

I am developing an Android app in xamarin in which I require to create a QR code from the data input by the user in various fields.
SO my question is can I do it with the help of Xamarin? If yes then please help me with any sample code or tutorial link.
ZXing.Net has a QR code generator built in. Take a look at that.
Something like this could do the job (following code not tested):
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = 200,
Width = 600
}
};
var bitmap = writer.Write("My content");
This should generate an image with the QR code. There are loads of other options you can mess with.
ZXing is also available as a component for Xamarin.Android, Xamarin.iOS and Windows Phone

Resources