Change angular-google-maps language dynamically

孤人 提交于 2019-12-05 21:44:26

In order to change map's language, a bunch of localized JS scripts need to be refetched anew. So, you can just try to refresh entire page (JS not Angular) providing wanted language via local storage for example:

@NgModule({ 
  imports: [ 
    AgmCoreModule.forRoot({ 
      apiKey: 'MY_KEY',
      language: localStorage && localStorage.gml || 'en'
    }),
  ]
})

to reload your page, use window.location.reload() method

StackBLITZ: https://stackblitz.com/edit/angular-google-maps-demo-f3xzhn?file=app%2Fapp.module.ts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!