Get google.maps.Map instance from a HTMLElement

后端 未结 5 708
故里飘歌
故里飘歌 2021-01-31 07:21

I have an existing map on a page. I can select that element using something along the lines of document.getElementById() to get the HTMLElement javascript object. Is it possible

5条回答
  •  忘掉有多难
    2021-01-31 08:10

    If you are using Google-map component from the Polymer project, you can get the existing map Dom like this:

    var map = document.querySelector('google-map');
    

    Once you have that, current instance of map can be accessed by:

    var currentMapInstance = map.map;
    

提交回复
热议问题