带有地标和描述的Google地图

时间:2013-12-26 14:32:17

标签: html google-maps iframe

如何创建Google地图链接以嵌入带有地标和描述的HTML网页,如下图所示?

Map example

1 个答案:

答案 0 :(得分:0)

@ sebastian,你需要使用谷歌地图API提供的“infowindow”。您可以看到此示例infowindow example

例如:

map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var InfoWindow = new google.maps.InfoWindow({
    map: map,
    position: myLocation,
    content:
        '<h1>Location pinned from HTML5 Geolocation!</h1>' +
        '<h2>Latitude: ' + position.coords.latitude + '</h2>' +
        '<h2>Longitude: ' + position.coords.longitude + '</h2>'
    });

变量'map'是您的地图画布,带有您的选项,而不是您使用地图创建新的InfoWindow,在此示例中,postion是我当前的位置(“var myLocation = new google.maps.LatLng(position) .coords.latitude,position.coords.longitude);“)。而内容方面,您可以使用html和变量来创建视觉效果。