Issue description
I created a newly project with angular-cli by ng init and implemented a simple map with two markers: a default and a custom one by setting [iconUrl] target to a static .svg file.
The map load both markers correctly on Chrome and Safari. But unfortunately, the custom icon didn't show up on Firefox. And I got error "InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable" on marker.js from 'maps.googleapis.com' when inspecting console.
Steps to reproduce and a minimal demo of the problem
I couldn't use Plunker to reproduce the issue since it works well on Plunker.
Current behavior
Custom marker icon by [iconUrl] don't show on Firefox, but show on Chrome and Safari.
Expected/desired behavior
The custom icon show on all the browsers
angular2 & angular-google-maps version
Other information
Here is my HTML and module files edited from the initial project created by ng init:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AgmCoreModule } from '@agm/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AgmCoreModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<agm-map [latitude]="10.8231" [longitude]="106.6297">
<agm-marker [iconUrl]="'/assets/marker-default.svg'" [latitude]="10.8231" [longitude]="106.6297"></agm-marker>
<agm-marker [latitude]="10.9231" [longitude]="106.7297"></agm-marker>
</agm-map>
I once had the same problem, but I wasn't sure if it was a browser specific problem, here's how I have solved it
markerIconUrl() {
return require('../../../images/image.png')
}
And then called the [iconUrl]=" markerIconUrl()"
Please let me know if this helped
Thank @Teebo, although not the problem in my case. Actually, I figured it out that the issue came from the .svg I used. The width attribute of <svg> tag was defined with typo mistake.
I'll close this issue because apparently, it's not @agm/core bug.
Most helpful comment
I once had the same problem, but I wasn't sure if it was a browser specific problem, here's how I have solved it
markerIconUrl() { return require('../../../images/image.png') }And then called the [iconUrl]=" markerIconUrl()"
Please let me know if this helped