谷歌地图信息框中的图像不显示

时间:2016-07-02 12:51:26

标签: javascript image google-maps-markers

我在VS 2015工作。

我需要创建一个标记来点击事件,从内容中弹出图像和信息。

我已尝试过所有内容,但我在该位置的图像似乎不起作用。

这是我到目前为止所做的:

<script>
  // Declare a varibale for map
  var map;
  // Get lattitude and longitude of Canberra Centre
  var canberraCentre = new google.maps.LatLng(-35.2792284, 149.1321033);

  // Initialise the map
  function initMap() {
    // Define the properties for Canberra Centre map
    var canberraMap = {
      center: canberraCentre,
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    // Create a map object for Canberra Centre
    // using canberraMap and the <div> element with id="googleMap"
    map = new google.maps.Map(document.getElementById("googleMap"), canberraMap);

    // Add markers
    addKinnMarker(map);

  }

  // Kinn marker
  function addKinnMarker(map) {
    var Kinn = new google.maps.LatLng(-35.279527, 149.133558);
    var markerKinn = new google.maps.Marker({
      position: Kinn,
    });

    markerKinn.setMap(map);

    var contentKinn =
      ' <h1>Kinn</h1>' +
      ' <img src="D:\Uni\WDP\Assignment_1\Restaurants\src\Restaurants\wwwroot\images\Kinn\KinnLogosmall.JPG" border="0" width="100px" height="30" align="left">' +
      ' <p>Kinn Thai Restaurant <br/>' +
      'It is located on 125 Bunda Street in the Canberra Centre<br>' +
      '<a href="http://www.kinnrestaurant.com.au/canberra/">Vist Kinn for more information</a>' +
      ' </p>';

      var infoKinn = new google.maps.InfoWindow({
        content: contentKinn
      });

      google.maps.event.addListener(markerKinn, 'click',
        function () {
          infoKinn.open(map, markerKinn);
        });
      }
</script>

1 个答案:

答案 0 :(得分:0)

不确定是否可以像这样设置对图像的引用(src属性)。尝试将图像保存在项目目录中,然后相应地更改路径。