Wykks / ngx-mapbox-gl

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

Cannot find namespace 'GeoJSON' #7

Closed WindMay closed 6 years ago

WindMay commented 6 years ago

Current bundle:

  "dependencies": {
    "@agm/core": "^1.0.0-beta.2",
    "@agm/snazzy-info-window": "^1.0.0-beta.2",
    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^5.0.0-rc0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "^ 5.0.0-rc0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "@ngrx/effects": "^4.1.1",
    "@ngrx/router-store": "^4.1.1",
    "@ngrx/store": "^4.1.1",
    "@ngrx/store-devtools": "^4.1.1",
    "@ngx-translate/core": "^8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "@swimlane/ngx-charts": "^6.1.0",
    "angular2-token": "^0.2.0-beta.12",
    "bootstrap": "^4.0.0-beta",
    "core-js": "^2.4.1",
    "d3": "^4.11.0",
    "express": "^4.15.3",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "mapbox-gl": "^0.42.0",
    "ngrx-store-localstorage": "^0.2.1",
    "ngx-mapbox-gl": "^1.0.0-beta.1",
    "ngx-toastr": "^6.5.0",
    "primeng": "^5.0.0-rc.0",
    "rxjs": "^5.5.2",
    "snazzy-info-window": "^1.1.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.5.0",
    "@angular/compiler": "^5.0.0",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
}

I get this when trying to use the module:


node_modules/ngx-mapbox-gl/src/app/lib/map/map.service.d.ts(49,25): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/marker/marker.component.d.ts(7,15): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/marker/marker.component.d.ts(7,31): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/feature.component.d.ts(3,69): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/feature.component.d.ts(3,85): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/feature.component.d.ts(6,15): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(10,12): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(10,28): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(10,54): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(10,80): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(25,25): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(25,41): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(26,28): error TS2503: Cannot find namespace 'GeoJSON'.
node_modules/ngx-mapbox-gl/src/app/lib/source/geojson/geojson-source.component.d.ts(26,44): error TS2503: Cannot find namespace 'GeoJSON'.```
WindMay commented 6 years ago

I fixed this with npm install --save @types/geojson and adding it to map.service

Wykks commented 6 years ago

Yes, I should mention that in the REAME. If you use typescript (almost all Angular users anyway), you should install mapbox types: @types/mapbox-gl (which include @types/geojson).

Thanks for the report !