Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectionsService.Route is using old javascript function name #243

Closed
greg-moffetco opened this issue Feb 21, 2023 · 5 comments
Closed

DirectionsService.Route is using old javascript function name #243

greg-moffetco opened this issue Feb 21, 2023 · 5 comments

Comments

@greg-moffetco
Copy link

When trying to use DirectionsService.Route, I get a Json parsing error. It turns out the string it's trying to deserialize is empty. I noticed that in #226, DirectionsRenderer.Route had the Javascript function name changed from "googleMapDirectionServiceFunctions.route" to "blazorGoogleMaps.directionService.route". I'm guessing this should have been done in DirectionsService.Route. as well.

@valentasm1
Copy link
Collaborator

Please provide simple example.
I need to reproduce.

@greg-moffetco
Copy link
Author

DirectionsExample.zip
The API Key is blank, but you won't need it since it errors before using it. The example is in Index.razor. I traced it back to DirectionsService.Route, where it calls the InvokeAsync on the JsObjectRef. Changing the function name to "blazorGoogleMaps.directionService.route" fixes it.

@valentasm1
Copy link
Collaborator

I will take a look next weekend or a bit earlier. On workations.

@valentasm1
Copy link
Collaborator

From getting null i get "REQUEST_DENIED" i need to enable somewhere. Like you know i am lazy. If it still dont work i will try investigate more.
https://www.nuget.org/packages/BlazorGoogleMaps/2.5.6
Speaking about deme this page would be enough.

@page "/"

@using GoogleMapsComponents
@using GoogleMapsComponents.Maps

<h1>Google Map</h1>
<div style="height:300px">
	<GoogleMap @ref=map Id="map1" Options=mapOptions Height="100%" OnAfterInit=OnAfterInit></GoogleMap>
</div>

@code {
	private GoogleMap? map;
	private MapOptions? mapOptions;

	protected override void OnInitialized()
	{
		mapOptions = new MapOptions()
		{
			Zoom = 13,
			Center = new LatLngLiteral()
			{
				Lat = 13.505892,
				Lng = 100.8162
			},
			MapTypeId = MapTypeId.Roadmap
		};
	}

	private async Task OnAfterInit()
	{
		DirectionsService service = await DirectionsService.CreateAsync(map!.JsRuntime);

		DirectionsRequest request = new()
			{
				Origin = "Orlando, FL",
				Destination = "Miami, FL"
			};

		DirectionsResult result = await service.Route(request);
		if (result == null)
		{
			Console.WriteLine("No result");
		}
		else
		{
			Console.WriteLine(result.Routes?.FirstOrDefault()?.Summary ?? "No routes?");
		}
	}
}

@valentasm1
Copy link
Collaborator

Closing due inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants