remove route with google map

后端 未结 8 2057
半阙折子戏
半阙折子戏 2020-12-03 20:29

I got a small app that use the Direction Service feature of Google Map. It is working well, I can change routes, but I have a small problem, where a user could go back to a

8条回答
  •  生来不讨喜
    2020-12-03 21:03

    I had similar problem, I tried with directionsDisplay.setMap(null); but it didn’t work.

    The problem was the directionsDisplay object which I created was declared locally.

    I changed it to global and every time the function is called, it will use the same global directionsDisplay object and make changes to it. This will definitely remove the previous route displayed on same object.

提交回复
热议问题