Angular Google maps custom marker icon
Asked Answered
R

3

10

I cannot create a custom marker. Even though I am passing an image path to the icon parameter I am still getting the default orange marker. Please tell me if you see anything wrong.

Directive's template:

<div id="searchMap" class="googleMaps-destinations">
<div class="google-maps">
    <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options">
        <ui-gmap-marker 
            ng-repeat="marker in search.origin_airports" 
            coords="marker.originMarker.location" 
            icon="marker.originMarker.icon.url" 
            fit="false" 
            idkey="'<< marker.originMarker.id >>'" >
        </ui-gmap-marker>
    </ui-gmap-google-map>
</div>

I am using : //maps.googleapis.com/maps/api/js?v=3&sensor=true with angular-google-maps/dist/angular-google-maps.js

Ragtime answered 1/4, 2015 at 19:6 Comment(1)
I just noticed that I cannot use animations as well.Ragtime
R
14

Missed that icon is an object.

 icon= '{url:    "//developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png" }'
Ragtime answered 1/4, 2015 at 19:17 Comment(1)
that worked. But I don't think that what the doc says angular-ui.github.io/angular-google-maps/#!/apiHeddie
T
14

I solved passing icon url through options property

Set something like this on controller

marker.options: {
    icon:'//developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"'
}

and then

<div id="searchMap" class="googleMaps-destinations">
   <div class="google-maps">
    <ui-gmap-google-map center="map.center" zoom="map.zoom" options="map.options">
    <ui-gmap-marker
        options="marker.options" 
        ng-repeat="marker in search.origin_airports" 
        coords="marker.originMarker.location"      
        fit="false" 
        idkey="'<< marker.originMarker.id >>'">
    </ui-gmap-marker>
</ui-gmap-google-map>

Tasiatasiana answered 2/4, 2015 at 14:41 Comment(1)
Looks like this issue, of having to set the icon through the options hash, has been reported: github.com/angular-ui/angular-google-maps/issues/1408Canonist
O
0

I have solved the custom icon problem Check with plunker Click here

options: {  draggable: false,      icon:'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png' }

Html is here

<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options">
        <ui-gmap-marker coords="marker.coords" options="marker.options" events="marker.events" idkey="marker.id">
        </ui-gmap-marker>
    </ui-gmap-google-map>
Optime answered 11/5, 2016 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.