Closed jacksonsfaria closed 2 months ago
I dont get it. It has position. Whats wrong with this one?
private async Task AddMarker()
{
var mapCenter = await _map1.InteropObject.GetCenter();
var marker = await AdvancedMarkerView.CreateAsync(_map1.JsRuntime, new AdvancedMarkerViewOptions()
{
Position = mapCenter,
Map = _map1.InteropObject,
Content = "<div style='background-color:blue'>My pin</div>",
});
await _bounds.Extend(mapCenter);
var position = await marker.GetPosition();
var latitude = position.Lat;
}
In my project it was also working. Now it doesn't work anymore.
Using
<script type="text/javascript" async src="https://maps.googleapis.com/maps/api/js?key=XXX&loading=async&v=beta&libraries=places,visualization,drawing,marker&callback=Function.prototype"></script>
TypeError: obj[functionToInvoke] is not a function
at Object.invoke (objectManager.js:716:55)
at blazor.server.js:1:3244
at new Promise (<anonymous>)
at y.beginInvokeJSFromDotNet (blazor.server.js:1:3201)
at Xt._invokeClientMethod (blazor.server.js:1:61001)
at Xt._processIncomingData (blazor.server.js:1:58476)
at Xt.connection.onreceive (blazor.server.js:1:52117)
at s.onmessage (blazor.server.js:1:80262)
objectManager.js:719
functionToInvoke: getPosition
args:
Oh. Now i think i get it. I is server side advanced marked demo dont work. I changed how map initilization work. Now using google recomemded way by js call. In this page _bounds were geting at after render async (wrong/bug) which had to be after MAP renders async. Updated/fixed demo Does it helps?
https://github.com/rungwiroon/BlazorGoogleMaps/commit/3f6a2d6d3cf8bd71a89856f7f198475b92159a04
_bounds = await LatLngBounds.CreateAsync(_map1.JsRuntime);
Tks!! Resolved!
Advanced Markers dont have method getPosition(), but have the property position. Any way to make the property accessible for reading?
I think that's going to be google's default.
https://developers.google.com/maps/documentation/javascript/reference/3.53/advanced-markers