Search code examples
azureazure-maps

Azure maps - change the color of a pin based on data driven styling


I am trying to create a data driven layer style that uses a boolean expression, but I am not sure how to make it work.

I have a Feature shape defined. Notice the property bag has an assigned property.

new atlas.data.Feature(new atlas.data.Point([-122.3802, 47.54384]), {
    leaseNo: '928928A',
    assigned: true
}),

Then for the SymbolLayer the Feature is assigned to uses a style definition as...

iconOptions: {
    image: [
        'match',
        ['get', 'assigned'],
        ['==', 'true'], 'marker-red',
        'marker-darkblue'
    ]
}

It retrieves the value of the assigned property and returns a marker based on whether the value is true or false.

However, it's not working, so my syntax isn't correct. Can someone help me with the syntax to make this work?


Solution

  • I found a solution using case.

    iconOptions: {
        image: [
            'case',
            ['get', 'assigned'], 'marker-red',
            'marker-darkblue'
        ]
    }