Hi, I am using TK.CustomMap (version: 2.1.97) package in Xamarin Forms (version: 4.6.0.847) with Xamarin Essentials (version: 1.5.3.2). Everything is working and Map is displaying correctly with following Code Snippet:
`public partial class MainPage : ContentPage
{
ObservableCollection _pins;
private bool _fromSignUp = false;
private TKCustomMap mapView = null;
public MainPage()
{
InitializeComponent();
}
protected async override void OnAppearing()
{
base.OnAppearing();
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
if(status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
if(status != PermissionStatus.Granted)
{
await DisplayAlert("", "Location is required", "Ok");
return;
}
}
AddMap();
MapSpan mapSpanBounds = mapView.MapRegion;
var searchFrom = new PlacesAutoComplete(false) { ApiToUse = PlacesAutoComplete.PlacesApi.Native, Bounds = mapSpanBounds, Placeholder = "Search Location" };
//searchFrom.SetBinding(Helpers.PlacesAutoComplete.PlaceSelectedCommandProperty, "PlaceSelectedCommand");
searchFrom.MinimumHeightRequest = 70;
searchFrom.PlaceSelectedCommand = new Command<IPlaceResult>(async (p) =>
{
IPlaceResult _fromPlace;
Position _from;
if (Device.RuntimePlatform == Device.iOS)
{
TKNativeiOSPlaceResult placeResult = (TKNativeiOSPlaceResult)p;
_fromPlace = placeResult;
_from = placeResult.Details.Coordinate;
}
else
{
TKNativeAndroidPlaceResult placeResult = (TKNativeAndroidPlaceResult)p;
_fromPlace = placeResult;
var details = await TKNativePlacesApi.Instance.GetDetails(placeResult.PlaceId);
_from = details.Coordinate;
}
var pin = new TKCustomMapPin
{
Position = _from,
Title = _fromPlace.Description,
ShowCallout = true,
IsDraggable = true
};
_pins.Clear();
_pins.Add(pin);
mapView.MoveToMapRegion(MapSpan.FromCenterAndRadius(_from, Distance.FromKilometers(2)), true);
});
Grid.SetColumnSpan(searchFrom, 2);
Grid.SetRow(searchFrom, 0);
grd.Children.Add(searchFrom);
}
private void AddMap(MapSpan bounds = null)
{
if (bounds != null)
mapView = new TKCustomMap(bounds);
else
mapView = new TKCustomMap();
mapView.SetBinding(TKCustomMap.PinsProperty, "Pins");
mapView.SetBinding(TKCustomMap.MapLongPressCommandProperty, "MapLongPressCommand");
mapView.IsRegionChangeAnimated = true;
mapView.IsShowingUser = true;
//mapView.HeightRequest = App.ScreenHeight - 280;
mapView.Pins = _pins;
mapView.MapLongPressCommand = new Command<Position>(position =>
{
var pin = new TKCustomMapPin
{
Position = position,
Title = "Your location",
ShowCallout = true,
IsDraggable = true
};
_pins.Clear();
_pins.Add(pin);
});
Grid.SetColumnSpan(mapView, 2);
Grid.SetRow(mapView, 1);
grd.Children.Add(mapView);
}
}`
However search places is not working whatever I type in AutoComplete entry. I have also created Google Places API with Billing Account and also enabled "Maps SDK for Android" and "Places API" libraries.
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaXXXXXXXXXXXXXXXXXXXXXXXXXX" />
But autocomplete list always come empty. If I try to use same Key with this Web Call then it works and get data correctly.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=AIzaXXXXXXXXXXXXXXXXXXXXXXXXXX
@malikirfan I am currently using xamarin maps,searchbar and collectionview to auto-complete and it works correctly, I use this library for google, the most complete I have found: GoogleApi
Hi, I am using TK.CustomMap (version: 2.1.97) package in Xamarin Forms (version: 4.6.0.847) with Xamarin Essentials (version: 1.5.3.2). Everything is working and Map is displaying correctly with following Code Snippet: `public partial class MainPage : ContentPage { ObservableCollection _pins;
private bool _fromSignUp = false;
private TKCustomMap mapView = null;
public MainPage()
{
InitializeComponent();
}
However search places is not working whatever I type in AutoComplete entry. I have also created Google Places API with Billing Account and also enabled "Maps SDK for Android" and "Places API" libraries.
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaXXXXXXXXXXXXXXXXXXXXXXXXXX" />
But autocomplete list always come empty. If I try to use same Key with this Web Call then it works and get data correctly.
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=AIzaXXXXXXXXXXXXXXXXXXXXXXXXXX
Can anyone please help me on it?