Angular-google-maps: AGM map icon resize

Created on 8 Feb 2018  路  6Comments  路  Source: SebastianM/angular-google-maps

I m using AGM map. Showing markers and marker icon dynamically. Showing user image as marker icon. The user images are different in size so its showing very large. Cant resize the icon. pls help.
The images are showing like below,
map4

Most helpful comment

copy of 517

https://github.com/SebastianM/angular-google-maps/issues/517

Basically you can make an object with the iconUrl for a marker and set the size from your component.ts file
Just make sure the url is correct to your needs

private icon = {
    url: require('../../../../assets/images/myImg.png'), 
    scaledSize: {
      height: 40,
      width: 20
    }
  };

Then as part of the marker html tag

<agm-marker [iconUrl="icon">

All 6 comments

Your "icons" should not be that large in the first place, it would take forever to load. You should resize them on your backend.

@lazarljubenovic , is there any possibility do this by using css?

@lazarljubenovic , actually I want to show user image inside the marker icon.

copy of 517

https://github.com/SebastianM/angular-google-maps/issues/517

Basically you can make an object with the iconUrl for a marker and set the size from your component.ts file
Just make sure the url is correct to your needs

private icon = {
    url: require('../../../../assets/images/myImg.png'), 
    scaledSize: {
      height: 40,
      width: 20
    }
  };

Then as part of the marker html tag

<agm-marker [iconUrl="icon">

timcblank is right, this a duplicate of #517; closing as such.

Found this comment by hrdkisback on StackOverflow which lets you dynamically change the map marker icon and specify the size:

[iconUrl]='{"url": marker,"scaledSize": {"height": 10, "width": 10}}'

https://stackoverflow.com/questions/50812678/add-user-image-to-agm-marker-in-angular-5#comment88677807_50812678

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PeterSisovsky picture PeterSisovsky  路  3Comments

DeveloperAdd007 picture DeveloperAdd007  路  3Comments

Subhojit1992 picture Subhojit1992  路  3Comments

dineshkumar20 picture dineshkumar20  路  3Comments

supran2811 picture supran2811  路  4Comments