Change icon of google map marker when onmouseover div (Google maps v3 api)

前端 未结 3 1687
陌清茗
陌清茗 2021-01-06 13:42

How do i change the icon of a marker on google maps when I mouseover the text in a div? I managed to change the marker icon onmouseover the marker in the map itself using

3条回答
  •  臣服心动
    2021-01-06 14:35

    I'm using Chrome. In the console, onmouseover the

    I get the error:

    Uncaught ReferenceError: marker1 is not defined

    If you set variable like this:

    function a() {
      var marker1 = "foo";
    }
    
    alert(marker1);
    

    marker1 is not accessible at "window" level. You have to write it like this:

    var marker1;
    
    function a() {
      marker1 = "foo";
    }
    
    alert(marker1);
    

提交回复
热议问题