Angular-google-maps: Custom marker icon via [iconUrl] don't show on Firefox

Created on 14 Oct 2017  路  2Comments  路  Source: SebastianM/angular-google-maps

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

  • angular: 4.2.4
  • angular/cli: 1.4.1
  • agm/core: 1.0.0-beta.1

Other information

Here is my HTML and module files edited from the initial project created by ng init:

  • app.module.ts
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 { }
  • app.component.html
<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>

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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dineshkumar20 picture dineshkumar20  路  3Comments

PeterSisovsky picture PeterSisovsky  路  3Comments

vamsibassetty08 picture vamsibassetty08  路  3Comments

nthonymiller picture nthonymiller  路  4Comments

supran2811 picture supran2811  路  4Comments