如何在谷歌地图v3中将图像添加到标记的InfoWindow中? [英] How to add an image to InfoWindow of marker in google maps v3?

查看:97
本文介绍了如何在谷歌地图v3中将图像添加到标记的InfoWindow中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张我想添加到标记的图像,stagleton.png,并且我有一个创建标记的功能。如何更改InfoWindow方法,以便图像也可以与InfoWindow中的文本一起显示?

I have an image that I want to add to a marker, stagleton.png, and I have a function to create a marker. How do I change the InfoWindow method so that the image is also displayed with the text in the InfoWindow?

function createMarker(name, latlng, mapsent)
{
    var marker = new google.maps.Marker({
                       position: latlng,
                       map: mapsent,
                       title: name   
                       });
    marker.info = new google.maps.InfoWindow({
              //when I add <IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> the maps will not load
      content: <IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> "My name is " + name

    });

    google.maps.event.addListener(marker, 'click', function(){
        marker.info.open(mapsent, marker);
    });
    return marker;
}


推荐答案

Try:

content: '<IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> My name is ' + name

这篇关于如何在谷歌地图v3中将图像添加到标记的InfoWindow中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆