Tride для интеграции Angular-Maps Bing в мой проект на Angular 5 Я делаю все, как в инструкции ( Angular-Maps-Github )
Импортированы все модули из Angular-карты вМой модуль ngModule
import { NgModule } from '@angular/core';
...
import {
MapModule, MapAPILoader, BingMapAPILoaderConfig,
BingMapAPILoader, WindowRef, DocumentRef,
MapServiceFactory, BingMapServiceFactory
} from "angular-maps";
...
@NgModule({
imports: [
...
MapModule.forRootBing()
...
],
providers: [
...
{
provide: MapAPILoader, deps: [], useFactory: MapServiceProviderFactory
}
...
]
})
и добавленная функция
export function MapServiceProviderFactory(){
let bc: BingMapAPILoaderConfig = new BingMapAPILoaderConfig();
bc.apiKey ="..."; // your bing map key
bc.branch = "experimental";
return new BingMapAPILoader(bc, new WindowRef(), new DocumentRef());
}
Попробуйте построить мой проект, и тогда у меня будет ошибка "Не удается найти пространство имен" Microsoft "".
В поисках немного больше выяснить, что должно добавить еще один импорт
import { Microsoft } from "bingmaps/scripts/MicrosoftMaps/Microsoft.Maps.All"
, но в этих файлах нет модуля Microsoft, поэтому я добавил
import { } from "bingmaps/scripts/MicrosoftMaps/Microsoft.Maps.All"
и этопомогает, у меня нет этого erorr, и у меня есть доступ к Microsoft.Map.
Когда я пытаюсь построить свой проект, возникает другая проблема:
Error: Unexpected value '[object Object]' imported by the module 'MyModule'. Please add a @NgModule annotation.
Error: Unexpected value '[object Object]' imported by the module 'MyModule'. Please add a @NgModule annotation
Теперь я не могу понять, в чем проблема?Может быть, у кого-то есть какие-то идеи, или, может быть, есть лучшие способы интегрировать карту Bing в проект Angular 5 ....