FORUM SBAGLIATO, SPOSTATEMI PLEASE GRAZIE
Non capisco, non riesco a fare i cluster di markers: continuo ad ottenere un milione di markers singoli e nella consolle di errore vedo marker.getPosition is not a function.
Se posto un po' di codice qualcuno mi illumina?
Here it is:
codice:var mymap; var mapExists = !!document.getElementById("nomemappa"); var allMyMarkers = []; var stylem = [ {stili mappa } ] var customLabel = { P: { label: '', icon: '/Google%20Maps%20Markers/orange_MarkerP.png' }, S: { label: '', icon: '/Google%20Maps%20Markers/blue_MarkerS.png' } }; function initMap() { if (mapExists) { mymap = new google.maps.Map(document.getElementById('macmap'), { center: new google.maps.LatLng(latitudine, longitudine), zoom: 12, styles: stylem }); var bounds = new google.maps.LatLngBounds(); var infoWindow = new google.maps.InfoWindow; //hfQS > ashx > xml downloadUrl(document.getElementById("hfQS").innerText, function (data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName('marker'); // Add a marker clusterer to manage the markers in locations array. var markerCluster = new MarkerClusterer(mymap, markers, { imagePath: '/Google%20Maps%20Markers' }); Array.prototype.forEach.call(markers, function (markerElem) { var name = markerElem.getAttribute('name'); var point = new google.maps.LatLng( parseFloat(markerElem.getAttribute('lat')), parseFloat(markerElem.getAttribute('lng'))); bounds.extend(point); var infowincontent = document.createElement('div'); var strong = document.createElement('h3'); strong.textContent = name; infowincontent.appendChild(strong); var myicon = customLabel[type] || {}; var marker = new google.maps.Marker({ map: mymap, position: point, label: myicon.label, icon: myicon.icon }); markerCluster.addMarker(marker, false); allMyMarkers.push(marker); marker.addListener('click', function () { infoWindow.setContent(infowincontent); infoWindow.open(mymap, marker); }); }); //fine for mymap.fitBounds(bounds); }); // Override map zoom level once our fitBounds function runs var boundsListener = google.maps.event.addListener((mymap), 'bounds_changed', function (event) { this.setZoom(14); google.maps.event.removeListener(boundsListener); }); } } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function () { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing() { } </script> <script src="/Scripts/markerclusterer.js"></script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=chiave&callback=initMap"></script>

Rispondi quotando
