Giter Site home page Giter Site logo

Comments (9)

vivet avatar vivet commented on August 19, 2024

You can try to specify false for the useHttpClientHandler parameter when registering AddGoogleApiClients().

Otherwise, I am not sure what you can do. I don't work with frontends, sorry

from googleapi.

Nguyenthanhtoa avatar Nguyenthanhtoa commented on August 19, 2024

Many thanks for your quick response.
I will try on this and take further investigating on the source code library.

from googleapi.

PontusHolmberg avatar PontusHolmberg commented on August 19, 2024

@Nguyenthanhtoa How did you fix this?

from googleapi.

Nguyenthanhtoa avatar Nguyenthanhtoa commented on August 19, 2024

Hi @PontusHolmberg,
I used the REST api to fetch the places data instead of library.
Reference: https://developers.google.com/maps/documentation/places/web-service/autocomplete
Feel free to ping me if you have any trouble when intergrating the REST api, I can share the sample code in .NET MAUI.

from googleapi.

PontusHolmberg avatar PontusHolmberg commented on August 19, 2024

@Nguyenthanhtoa
Oh, okey.
I actually solved the issue it self. Turns out that SetProxy is not supported on iOS by Maui even in .net8.
So i changed the HttpClientFactory and removed the Proxy argument when creating a new HttpClientHandler.

from googleapi.

Nguyenthanhtoa avatar Nguyenthanhtoa commented on August 19, 2024

Yes, sure. Great to hear that!

from googleapi.

remi-appsolu avatar remi-appsolu commented on August 19, 2024

@Nguyenthanhtoa Oh, okey. I actually solved the issue it self. Turns out that SetProxy is not supported by Maui even in .net8. So i changed the HttpClientFactory and removed the Proxy argument when creating a new HttpClientHandler.

Can you explain a little more ? I am facing the same issue in maui but in GoogleMaps.Geocode.LocationGeocode and i never created a HttpClientHandler. Thanks.

from googleapi.

PontusHolmberg avatar PontusHolmberg commented on August 19, 2024

@remi-appsolu I downloaded/cloned the github project and added it to my VS project, so I could modify the library.
Then inside HttpClientFactory you will find the function GetDefaultHttpClientHandler.
In there, I just changed

var httpClientHandler = new HttpClientHandler
        {
            Proxy = webProxy
        };

To
var httpClientHandler = new HttpClientHandler();

That way it will never call SetProxy.

from googleapi.

Nguyenthanhtoa avatar Nguyenthanhtoa commented on August 19, 2024

Hi @remi-appsolu ,

As you can see in my issue description, the GoogleApi works properly on Android, but not on iOS. So, my workaround on iOS is using HttpClient to send an request to https://maps.googleapis.com/maps/api/place/autocomplete/json and get the places result like this:
using (var client = new HttpClient())
{
var path = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=SEARCH_STRING&key=YOUR_API_KEY&types=(cities)&components=country:YOUR_COUNTRY_CODE";

HttpResponseMessage response = await client.GetAsync(path);

if (response.IsSuccessStatusCode)
{
    var json = await response.Content.ReadAsStringAsync();
    var predictionResponse = JsonConvert.DeserializeObject<PlacePredictionResponse>(json);
    return predictionResponse.Predictions
        .Select(p => new CityOfResidence { Name = p.Description, PlaceId = p.PlaceId })
        .OrderBy(c => c.Name).Take(10).ToList();
}

}
Do not forget to add Newton.Json & handle exception
Ref: https://developers.google.com/maps/documentation/places/web-service/autocomplete

from googleapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.