Is your feature request related to a problem?
No response
Describe the solution you'd like
I'd like to be able to add custom functions/utilities to the JavaScript interop module to perform more advanced interactions with the rendered map. For example, orbiting around a specific point on the map as is demonstrated in the example Animate map camera around a point.
The implementation of this is simple, but could be more advanced, combining many routines/API usages into one utility function.
function rotateCamera(timestamp) {
clamp the rotation between 0 -360 degrees
Divide timestamp by 100 to slow rotation to ~10 degrees / sec
map.rotateTo((timestamp / 100) % 360, {duration: 0});
Request the next frame of the animation.
requestAnimationFrame(rotateCamera);
}
The main need for extensibility comes from my understanding that only the MapLibre.razor.js interop library has first-class access to the map instances (and options) on the page. It's likely possible to "new up" some reference to the maps, but first-party extensibility would be better.
Describe alternatives you've considered
I made a new component named MapLibre2 that extends MapLibre. This works to some degree and would need some more thought if this is a the preferred method, but most of the extensibility scenarios require running JavaScript. With that, I think support for extending the JavaScript interop module could be explored.
MapLibre JS Reference
See this example from MapLibre: Animate map camera around a point
Example Usage
// Using custom `Orbit` method
private MapLibre? _map { get; set; }
...
_map.Orbit(duration: 2000);
Worth noting this is an overly simple articulation of the idea. It would be up to the consumer to design the new APIs/method signatures.
Additional context
I think it's fair to say that it's best if this library continues to just wrap MapLibre. Sure, a bunch of extensions/utilities would be helpful, but they would add to the maintenance overhead of the project.
Instead, I propose a discussion around how the project can given consumers the ability to extend the interop library with their own functions while still using the same API (core MapLibre Razor component).
Contribution
Is your feature request related to a problem?
No response
Describe the solution you'd like
I'd like to be able to add custom functions/utilities to the JavaScript interop module to perform more advanced interactions with the rendered map. For example, orbiting around a specific point on the map as is demonstrated in the example Animate map camera around a point.
The implementation of this is simple, but could be more advanced, combining many routines/API usages into one utility function.
The main need for extensibility comes from my understanding that only the
MapLibre.razor.jsinterop library has first-class access to the map instances (and options) on the page. It's likely possible to "new up" some reference to the maps, but first-party extensibility would be better.Describe alternatives you've considered
I made a new component named
MapLibre2that extendsMapLibre. This works to some degree and would need some more thought if this is a the preferred method, but most of the extensibility scenarios require running JavaScript. With that, I think support for extending the JavaScript interop module could be explored.MapLibre JS Reference
See this example from MapLibre: Animate map camera around a point
Example Usage
Worth noting this is an overly simple articulation of the idea. It would be up to the consumer to design the new APIs/method signatures.
Additional context
I think it's fair to say that it's best if this library continues to just wrap MapLibre. Sure, a bunch of extensions/utilities would be helpful, but they would add to the maintenance overhead of the project.
Instead, I propose a discussion around how the project can given consumers the ability to extend the interop library with their own functions while still using the same API (core
MapLibreRazor component).Contribution