none
leave 'enableClickedStyle' selected state RRS feed

  • Question

  • Hi,

    after adding a pushpin with options 'enableClickedStyle = true' and clicking the pin, it gets into a visual selected state. How to leave this state an got back to normal visual behavior?

    Thanks Steffen

    Friday, July 29, 2016 12:00 AM

Answers

  • I found another way!

    I used the undocumented property '_state' of pushpin.

    I extended the typescript model...

    export class Pushpin implements IPrimitive {
            public metadata: any;
    
            public _state: number;
    
    [...]

    and set it to state 4 = clicked.

    pushpin._state = 4;
    I know thats no recommended way but it works like charm and now me map component works exact like the select userstory on the bing map site.



    Friday, July 29, 2016 11:21 PM

All replies

  • I'll double check with the team to see if their is a more elegant solution, but I see two ways to do this.

    1. Click the pushpin again to unselect it.
    2. If you want to unselect it programmatically, you can disable the click style then re-enable it. For example:

    pushpin.setOptions({ enableClickedStyle: false });
    pushpin.setOptions({ enableClickedStyle: true });

    Not the pretties solution, but works well.


    [Blog] [twitter] [LinkedIn]

    Friday, July 29, 2016 7:52 PM
  • I found another way!

    I used the undocumented property '_state' of pushpin.

    I extended the typescript model...

    export class Pushpin implements IPrimitive {
            public metadata: any;
    
            public _state: number;
    
    [...]

    and set it to state 4 = clicked.

    pushpin._state = 4;
    I know thats no recommended way but it works like charm and now me map component works exact like the select userstory on the bing map site.



    Friday, July 29, 2016 11:21 PM
  • When I try that it doesn't seem to do anything until the map view is refreshed. Moving the map slightly triggers the label/pushpin collision to recalculate and rerender that layer. As you said, using undocumented or hidden properties/functions isn't recommended. I've updated the documentation with the information I provided in my initial response. If we get feedback from other devs we will consider adding a function for changing the state via a public function.

    [Blog] [twitter] [LinkedIn]

    Friday, July 29, 2016 11:46 PM