-
Notifications
You must be signed in to change notification settings - Fork 141
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
Errors when import MapService #19
Comments
Hi! This is done on purpose. |
I have made my own custom component for app. And put it inside mgl-map to have the same instance of MapService. I am using some functions from it and mapinstance property. |
What are you using from Edit: oh, I see, you want to add custom component working with mgl-map. Hum, I haven't thought about that yet. I don't list |
i am using getCurrentViewportBbox(). I understand that i can calculate it from map instance directly. At first i thought to hook on load event and get map instance from there as you suggest. But i thought that it is not good idea because i would have to make a wrapper component with your map and my component and put some logic there using hooks. I just want my component to be like Edit: Ok. Let me know if you find a solution. |
Yup, it's fine, I wanted to do a proper way to add custom component, in order to do some extension like a ngx-mapbox-gl-draw for example. For this use case, exposing the |
you can access the internal mapInstance:MapboxGl.Map like this
For this example the wrapper provides the input fitBounds, so to access the internal map instance is not necessary and it is not recommended, but is always good to have alternatives. <==My Original comment/question ==> I'm doing this. fitToKenya() { ----------app.module EDIT1: PD: I know to add a layer or fit bounds there are some directives (mgl-layer/fitBounds)... but I need the reference to mapInstance to do a custom modification, but is easier to exemplify with something basic. note: I also saw #25. |
@shadower01 You should use the load event to get the Map instance. See this example : I won't say that it's not recommended. It's just about whenever or not you want to do something declaratively (using template) or imperatively (calling mapbox-gl function directly). And sometimes, things "feels" better imperatively. |
I am using ngx-mapbox-gl:1.0.0-beta.5 and I can't import MapService to my component. If i write like this
i have an error while compiling
if i change import to
Compiled successfully. But i have errors in browser console like
I think that it is an error in ng-packagr or something with it's config. Because if i use your source files in my app everything is fine and work as expected.
The text was updated successfully, but these errors were encountered: