Изображение Google Maps API Карт кластера не будет отображаться - PullRequest
0 голосов
/ 13 марта 2019

Итак, я создаю веб-сайт, использующий API Google Maps, и пытаюсь заставить работать кластеры маркеров. У меня работает кластеризация, но изображение не отображается вообще. Если вы присмотритесь, вы заметите число 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',});

Я просто хочу использовать изображение m1.png, которое документы Google показывают на странице кластеризации маркеров. Кто-нибудь может указать мне правильное направление?

1 Ответ

0 голосов
/ 13 марта 2019

Понял, похоже, что для отображения изображения вам просто нужно использовать URL, который они используют.developers.google.com/maps/documentation/javascript/examples/… в качестве пути к изображению, даже несмотря на то, что он предлагает вам загрузить их

...