Google Maps API Map Cluster图像不会显示

时间:2019-03-13 14:53:02

标签: api maps markerclusterer

因此,我正在建立一个使用google maps api的网站,并且我正在尝试使标记簇工作。我有群集工作,但图像根本没有显示。如果仔细观察,您会注意到两个标记之间的数字2

enter image description here

let markers = [];

  // create empty array to hold all story modal windows
  let story_windows = [];

  // loop through the JSON data
  $.each(story, function(key, data) {

    // set the latitude/longitude and create a new LatLng object
    let latLng = new google.maps.LatLng(data.latitude, data.longitude);

    // Create a marker to place on the map
    let marker = new google.maps.Marker({
      // takes a latLng object
      position: latLng,
      // where to place the marker, ie the map
      map: map,
      // what image to use for the marker
      icon: 'markerImage.png',
      // set a pop up title for the marker, use the stories title
      title: data.title
    });

    markers.push(marker);


    // set the modal content with the data from the story
    let modalContent = createModalWindow(data.title, data.image, data.body, data.audio);

    // add the current stories modal window to the array
    story_windows.push(modalContent);

    // append the current story to the menu dropdown and set it's data- values to display the modal
    $("#drop-menu").append(`<a class='dropdown-item' data-index='${key}' data-gps='${latLng}'>${data.title}</a>`);

    // show modal window when marker is clicked
    google.maps.event.addListener(marker, 'click', function() {

      // center map on marker when clicked
      map.panTo(marker.getPosition());

      // set the html content of the modal window
      $("#myModal .modal-content").html(modalContent);

      // show the modal window
      $('#myModal').modal('show');

    }); // end event listener

  }); // end foreach

  // Add a marker clusterer to manage the markers.
  let markerCluster = new MarkerClusterer(map, markers, {imagePath: '/cluster_images/m1.png',});

我只想使用Google文档在标记聚类页面上显示的m1.png图像。谁能指出我正确的方向?

1 个答案:

答案 0 :(得分:0)

找到答案后,似乎要显示该图像,您只需使用其使用的URL。 developer.google.com/maps/documentation/javascript/examples/…作为图像路径,即使它告诉您下载它们