remove route with google map

后端 未结 8 2061
半阙折子戏
半阙折子戏 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:15

    Since on each call, new instance of DirectionRenderer created thats why each new instance is unaware of previous instance.

    Move

    var directionsDisplay = new google.maps.DirectionsRenderer();
    

    to the global(at the top where all other Global variables have been initialized.)

    By doing so, each time you would be using single instance of DirectionRenderer.

提交回复
热议问题