// : <script src="https://maps.api.2gis.ru/2.0/loader.js?pkg=full"></script> <script type='text/javascript'> var map; DG.then(function () { markers = DG.featureGroup(); map = DG.map('map', { // 'map' div id center: [44.98, 10.89], zoom: 2, minZoom: 2, fullscreenControl: false, zoomControl: false, inertia: false, doubleClickZoom: false }); getdaystat(0); // }); </script>
function getdaystat(st) { // if (st!=0){ var url="http://smartgekko.ru/whoscanme/core/scanbase/"+st+"/shosts?rnd=" + Math.round(Math.random() * 100000); } else { var url="http://smartgekko.ru/whoscanme/scaner_hosts?rnd=" + Math.round(Math.random() * 100000); } // var xrequest=new XMLHttpRequest(); xrequest.open("GET",url,false); xrequest.send(""); var result=xrequest.responseText; var marker; var citycnt=0; // . . var splitArray = result.split(/\r\n/); var cityArray = new Array(splitArray.length); var countryArray = new Array(splitArray.length); // markers.removeFrom(map); markers.clearLayers(); // . - for (var i = 0; i < splitArray.length; i++){ var splitString = splitArray[i].split(","); var pip = splitString[0]; var pcountry = splitString[1]; var pcity = splitString[2]; citycnt=0; for (var j = 0; j < cityArray.length; j++){ if((pcity==cityArray[j])&&(pcountry==countryArray[j])) citycnt++; } var myIcon = DG.icon({ iconUrl: '/whoscanme/images/i2.png', // iconSize: [20, 34], iconAnchor: [10-citycnt*2, 33+citycnt*2] // }); marker = DG.marker([splitString[3],splitString[4]],{icon: myIcon,alt:pip,title:pip+"\n"+pcountry+", "+pcity})// .on('click',function(e) { getmarkerinfo(this.options.alt); // . }) .addTo(markers); cityArray[i]=pcity; countryArray[i]=pcountry; markers.addTo(map);// } }
Source: https://habr.com/ru/post/358056/
All Articles