change content infowindow maps v3

后端 未结 3 1955
时光说笑
时光说笑 2021-02-07 13:26

I am trying to make it possible to change the content that shows up inside a DIV that is the content of an infowindow. I have been able to change the content from Hello to YO in

3条回答
  •  借酒劲吻你
    2021-02-07 14:04

    Best is to create the content of the InfoWindow not by using a HTML string, but with a DOM Element. So replace:

    new google.maps.InfoWindow({
            content: '
    Hello
    ' });

    with:

    var domElement = document.createElement('div');
    domElement.innerHTML = '
    Hello
    '; new google.maps.InfoWindow({ content: domElement });

    Now you can easily access the div with document.getElementById("content"); and do all the DOM manipulation you want.

提交回复
热议问题