V
V
vita_run2018-06-18 12:19:22
JavaScript
vita_run, 2018-06-18 12:19:22

Why doesn't he see the getPosition function?

I display photos on the map in the form of markers that need to be clustered. Displays an error: `Uncaught TypeError: marker.getPosition is not a function` in the file markerclusterer.js I perform
5b27d09fd695d459218604.png
marker clustering according to the instructions from the official GoogleMaps website. How to fix the error?
I include the following scripts:

<script src="https://maps.googleapis.com/maps/api/js?key=****"></script>
    <script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js"></script>

Marker Unloading Script and Clustering
var map;
       function initialize() {
        // Prepare markers array
    
        var markers = [];
        <% photoList.forEach(function(photo) { %>
        markers.push({
            latLan: new google.maps.LatLng("<%= photo.latit %>", "<%= photo.longit %>"),
            img: "<%= photo.preview %>"
        });
        <% }) %>
    
        //определение карты
        map = new google.maps.Map(document.getElementById("map"), {
            zoom: 8,
            center: new google.maps.LatLng(48.42216, 44.31308),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });
    
        markers.forEach(function (item) {
            new RichMarker({
                position: item.latLan,
                map: map,
                content: '<div class="google-marker"><img src="'+item.img+'"/></div>',
                shadow: 0
            });
        });
        //Кластеризация
        var markerCluster = new MarkerClusterer(map, markers,
            {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question