Wykks / ngx-mapbox-gl

Angular binding of mapbox-gl-js
https://wykks.github.io/ngx-mapbox-gl
MIT License
346 stars 140 forks source link

A way to use mapbox plugins? #63

Closed HMubaireek closed 4 years ago

HMubaireek commented 6 years ago

Hi,

I've been looking to find a way to use mapbox plugins, specifically mapbox-gl-rtl-text.

I've been thinking we could use it in NgxMapboxGLModule.withConfig but that is not supported.

What is the way to do it?

sroettering commented 6 years ago

I would also like to use plugins, namely mapbox-gl-draw. As far as I can tell it would be enough for me to be able to write my own control directive, but that is not an option right now as MapService and ControlComponent are not exposed in the library.

calbear47 commented 6 years ago

I have the drawing tools working with this project.

I accomplished it by doing the following:

Load the css in angular.json

            "styles": [
              "src/styles.scss",
              "node_modules/mapbox-gl/dist/mapbox-gl.css",
              "node_modules/@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css"
            ]

Import the drawing module into your component;

import * as MapboxDraw from '@mapbox/mapbox-gl-draw';

On load, add the control to your map;


@ViewChild('map') map;

  ngAfterViewInit() {
    const draw = new MapboxDraw();
    this.map.load.pipe(take(1)).subscribe(() => {
      this.map.MapService.addControl(draw, 'top-right');
    });
  }
raysuelzer commented 5 years ago

I think it would be good if the created exposed ControlComponent to the public API. This would allow creation of custom directives, like Draw.

raysuelzer commented 5 years ago

Here is a PR with that I think is a more elegant solution and would allow community based plugins.

https://github.com/Wykks/ngx-mapbox-gl/pull/79

amirofy2002 commented 5 years ago

after installing mapbox-gl-rtl-text

following errors occured:


**ERROR in ./node_modules/@mapbox/mapbox-gl-rtl-text/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\My Data\Angular\BehzistiSearch\node_modules\@mapbox\mapbox-gl-rtl-text'
ERROR in ./node_modules/@mapbox/mapbox-gl-rtl-text/index.js
Module not found: Error: Can't resolve 'path' in 'C:\My Data\Angular\BehzistiSearch\node_modules\@mapbox\mapbox-gl-rtl-text'**
rrecio commented 4 years ago

I would also like to use plugins, namely mapbox-gl-draw. As far as I can tell it would be enough for me to be able to write my own control directive, but that is not an option right now as MapService and ControlComponent are not exposed in the library.

It would be awesome to use mapbox draw

dmytro-gokun commented 4 years ago

As far as i understand this was solved by #79 and should be available to do with the latests version of the library (4.8.1). Thus, i'm closing this issue. If someone thinks there's still work to do - please chime in and we'll figure it out.

ArmaProjects commented 4 years ago

@amirofy2002 mentioned above error when the mapbox-gl-rtl-text connected with addControl method. The error is still there. It seems that mapbox-gl-rtl-text differs from another plugins.

Does anyone has an idea how to connect mapbox-gl-rtl-text to a project?

dmytro-gokun commented 4 years ago

@ArmaProjects This issue is closed. Please create a new one and provide a reproduction project (preferrably, using the stackblitz template supplied). Then, if someone has time, they may help you.