Untitled
unknown
plain_text
a year ago
5.5 kB
2
Indexable
Never
var omrane=omrane||{}; // Array to push MArkers. var markerArray = []; // Array to push markers LatLng values to fitBounds. var markersBoundsArray = []; var mymap = null; /*jshint esnext: true */ omrane.mapInit = function (divMapId, arrayInfos, centerCountry) { arrayInfos = JSON.parse(JSON.stringify(arrayInfos)); // mymap = L.map(divMapId, { scrollWheelZoom: false }); mymap = L.map(divMapId, { center: [33.5731104, -7.5898434], zoom: 7, minZoom: 5, maxZoom: 18 }); L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: null }).addTo(mymap); L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}{r}.png', { attribution: null, subdomains: 'abcd', }).addTo(mymap); // call to init function // omrane.fetchData(arrayInfos, centerCountry); // omrane.scrollWheelZoom(mymap); }; // omrane.fetchData = function (arrayInfos, centerCountry) { // // Set custom icon // var customIcon = L.icon({ // iconUrl: '/bundles/omranesocle/refonte/images/css/original_marker.png', // iconSize: [40, 'auto'], // size of the icon // iconAnchor: [0, 16], // popupAnchor: [20, -40] // }); // // Creating markercluster // var markersCluster = L.markerClusterGroup({ // iconCreateFunction: function(cluster) { // var childCount = cluster.getChildCount(); // var size = 40; // var c = ' marker-cluster-'; // if (childCount < 10) { // c += 'small'; // } else if (childCount < 100) { // size = 55; // c += 'medium'; // } else { // size = 70; // c += 'large'; // } // return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', className: 'marker-cluster' + c, iconSize: new L.Point(size, size) }); // } // }); // for (locId in arrayInfos) { // var ezLocationInfos = arrayInfos[locId]; // var locationId = locId; // if(typeof ezLocationInfos["locationId"] !== 'undefined') { // locationId = ezLocationInfos["locationId"]; // } // objectLatitude = ezLocationInfos["lat"]; // objectLongitude = ezLocationInfos["lng"]; // marker = L.marker([objectLatitude, objectLongitude], {icon : customIcon}); // omrane.mapSetMessage(marker, locationId, mymap); // markerArray.push(marker); // markersCluster.addLayer(marker); // markersBoundsArray.push(L.latLng(objectLatitude, objectLongitude)); // } // // Add Marker cluster Layer to map // mymap.addLayer(markersCluster); // // Call to fitbounds function // omrane.fitbBounds(mymap, centerCountry); // // Call to custom search function // omrane.customSearch(mymap, customIcon); // }; // omrane.reloadMap = function (divMapId, arrayInfos) { // arrayInfos = JSON.parse(JSON.stringify(arrayInfos)); // mymap.remove(); // mymap = L.map(divMapId); // L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { // attribution: null, // zoom: 10, // maxZoom: 18, // accessToken: 'pk.eyJ1IjoiYWxpOTk2IiwiYSI6ImNqaTV0dXRpZDA0Z3IzbHBrOTE3ZThwZmIifQ.s5AoPuGA72HefSctxLAyzw' // }).addTo(mymap); // // call to init function // omrane.fetchData(arrayInfos); // }; // omrane.fitbBounds = function (mymap,centerCountry) { // // Fitbounds // if(centerCountry) { // var corner1 = L.latLng(34.686667, -1.911389), //Oujda // corner2 = L.latLng(23.6975, -15.937), //Dakhela // bounds = L.latLngBounds(corner1, corner2); // mymap.fitBounds(bounds, {animation: false}); // } else { // var bounds = new L.LatLngBounds(markersBoundsArray); // mymap.fitBounds(bounds); // mymap.setZoom(12); // } // }; // omrane.customSearch = function (mymap, customIcon) { // mymap.addControl( new L.Control.Search({ // textPlaceholder: 'rechercher...', // url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}', // jsonpParam: 'json_callback', // propertyName: 'display_name', // position:'topleft', // where do you want the search bar? // propertyLoc: ['lat','lon'], // zoom: 10, // set zoom to found location when searched // marker: L.marker([0,0],{draggable: true,opacity:.5,icon : customIcon,radius:30}).bindPopup('Drag me'), // }) ); // }; // omrane.mapSetMessage = function (marker, ezLocationId, mymap) { // marker.addEventListener('click', function () { // href = '/content/location/' + ezLocationId + '/map'; // if (jQuery("#prefix_langue").length > 0) { // href = "/" + jQuery("#prefix_langue").attr('href') + href // } // jQuery.ajax({ // url: href, // success: function (data) { // marker.bindPopup(data); // marker.openPopup(); // } // }); // mymap.setView([marker.getLatLng().lat, marker.getLatLng().lng]); // }); // }; // omrane.scrollWheelZoom = function (mymap) { // if (viewportWidth <= 1024) { // mymap.scrollWheelZoom.disable(); // } // }