Making a Google Maps marker show a specific div when clicked

て烟熏妆下的殇ゞ 提交于 2019-12-01 11:08:14

You need to have a relation between the marker and the div, currently there isn't any.

Instead of an ID like div-sg this could be e.g. div0 , where the number indicates the index of the marker.

Then it's no problem to access the div:

   //access the node
 var content=document.getElementById('div'+i)
   //create a copy of the node
 .cloneNode(true);
   //remove the id to avoid conflicts
 content.removeAttribute('id');
   //make it visible  
 content.style.display='block';
   //apply the content  and open the infoWindow 
 infowindow.setContent(content);
 infowindow.open(map, marker);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!