Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more flexibility to markers #1580

Closed
tbnovaes opened this issue Jan 21, 2019 · 8 comments
Closed

Add more flexibility to markers #1580

tbnovaes opened this issue Jan 21, 2019 · 8 comments

Comments

@tbnovaes
Copy link

As of now, the only way to add markers is by using an image. It would be great to be able to also use icons (Eg.: font awesome) and to set colors.

@IsaacSomething
Copy link
Contributor

technically you can do this. You just need to add https://github.com/ackerapple/agm-overlays
and then just map the lat and long to the same lat and long as your marker

<agm-marker #marker [latitude]="lat" [longitude]="lng">
   <agm-overlay [latitude]="lat" [longitude]="lng">
       <i class="fas fa-map-marker"></i>
    </agm-overlay>
</agm-marker>

@MathiasHC
Copy link

I can confirm the above works @tbnovaes 💪
– You can also change the [iconUrl] on the agm-marker, to hit the font pack – you might need a "handle" for this though.

@tbnovaes
Copy link
Author

tbnovaes commented Feb 8, 2019

@MathiasHC I tried the @IsaacSomething solutions, but what happened to me was that I had the default marker pin, and over that the overlay... so I end up with 2 pins, the one I wanted and the one I didn't want.

@IsaacSomething
Copy link
Contributor

You can just make the marker icon source in agm-marker null

@tbnovaes
Copy link
Author

tbnovaes commented Feb 8, 2019

@IsaacSomething Okay, I'll try it, thank you! Anyway I still think it would be a good addition to the marker to have it. Installing a new package just for that is not the best solution.

EDIT: setting [imgUrl]="null" does not work and using imgUrl="null"will make a request to /null and generate an error loading the asset that does not exist. Using [opacity]="0" works.

@stale
Copy link

stale bot commented May 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 9, 2019
@stale stale bot closed this as completed May 16, 2019
@ghost
Copy link

ghost commented May 30, 2019

you can pass an Icon or a Symbol literal to iconUrl and it should work.

@ghost ghost removed the stale label May 30, 2019
ghost pushed a commit that referenced this issue Jul 16, 2020
allow AgmMarker `iconUrl` to be a GoogleSymbol or an Icon type.

fixes: #1740
fixes: #1622
fixes: #1580
probably fixes a bunch more, since this was often requested.
@id1945
Copy link

id1945 commented Jan 20, 2021

technically you can do this. You just need to add https://github.com/ackerapple/agm-overlays
and then just map the lat and long to the same lat and long as your marker

<agm-marker #marker [latitude]="lat" [longitude]="lng">
   <agm-overlay [latitude]="lat" [longitude]="lng">
       <i class="fas fa-map-marker"></i>
    </agm-overlay>
</agm-marker>

Thanks a lot :)

    <agm-map *ngIf="location"
        [(latitude)]="location.latitude"
        [(longitude)]="location.longitude"
        [(zoom)]="location.zoom"
        [(mapTypeId)]="location.mapType"
        [zoomControl]="location?.zoomControl ? location.zoomControl : false"
        [scrollwheel]="location?.scrollwheel ? location.scrollwheel : false"
        [mapTypeControl]='location?.mapTypeControl ? location.mapTypeControl : false'
        [streetViewControl]='location?.streetViewControl ? location.streetViewControl : false'
        [fullscreenControl]="location?.fullscreenControl ? location.fullscreenControl : false">
        <agm-marker *ngFor="let m of location?.markers;"
            [(latitude)]="m.latitude"
            [(longitude)]="m.longitude"
            [label]="m.label"
            [iconHeight]="20"
            [iconWidth]="20"
            [markerDraggable]="m.draggable">
            <agm-overlay
                [(latitude)]="m.latitude"
                [(longitude)]="m.longitude">
                <div>
                    <i *ngIf="!isBase64(m.iconUrl)" [class]="m.iconUrl" [style.color]="m.color" style="height: 20px; width: 20px;"></i>
                    <img *ngIf="isBase64(m.iconUrl)" [src]="m.iconUrl" height="20" width="20">
                </div>
            </agm-overlay>
        </agm-marker>
    </agm-map>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants