', "https://2474you.com/wp-content/themes/classiera/images/icon-services.png"],
];
var mapopts;
if(window.matchMedia("(max-width: 1024px)").matches){
var mapopts = {
dragging:false,
tap:false,
};
};
var map = L.map('classiera_main_map', mapopts).setView([0,0],1);
var roadMutant = L.gridLayer.googleMutant({
maxZoom: 20,
type:'roadmap'
}).addTo(map);
var markers = L.markerClusterGroup({
spiderfyOnMaxZoom: true,
showCoverageOnHover: true,
zoomToBoundsOnClick: true,
maxClusterRadius: 10
});
markers.on('clusterclick', function(e) {
map.setView(e.latlng, 13);
});
var markerArray = [];
for (var i = 0; i < addressPoints.length; i++){
var a = addressPoints[i];
var newicon = new L.Icon({iconUrl: a[3],
iconSize: [36, 51], // size of the icon
iconAnchor: [20, 10], // point of the icon which will correspond to marker's location
popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor
});
var title = a[2];
var marker = L.marker(new L.LatLng(a[0], a[1]));
marker.setIcon(newicon);
marker.bindPopup(title, {minWidth:"400"});
marker.title = title;
//marker.on('click', function(e) {
//map.setView(e.latlng, 13);
//});
markers.addLayer(marker);
markerArray.push(marker);
if(i==addressPoints.length-1){//this is the case when all the markers would be added to array
var group = L.featureGroup(markerArray); //add markers array to featureGroup
map.fitBounds(group.getBounds());
}
}
var circle;
map.addLayer(markers);
map.dragging.disable();
map.scrollWheelZoom.disable();
function getLocation(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(showPosition);
}else{
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position){
jQuery('#latitude').val(position.coords.latitude);
jQuery('#longitude').val(position.coords.longitude);
var latitude = jQuery('#latitude').val();
var longitude = jQuery('#longitude').val();
map.setView([latitude,longitude],13);
circle = new L.circle([latitude, longitude], {radius: 2500}).addTo(map);
}
jQuery('#getLocation').on('click', function(e){
e.preventDefault();
getLocation();
});
//Search on MAP//
var geocoder;
function initialize(){
geocoder = new google.maps.Geocoder();
}
jQuery("#classiera_map_address").autocomplete({
//This bit uses the geocoder to fetch address values
source: function(request, response){
geocoder = new google.maps.Geocoder();
geocoder.geocode( {'address': request.term }, function(results, status) {
response(jQuery.map(results, function(item) {
return {
label: item.formatted_address,
value: item.formatted_address,
latitude: item.geometry.location.lat(),
longitude: item.geometry.location.lng()
}
}));
})
},
//This bit is executed upon selection of an address
select: function(event, ui) {
jQuery("#latitude").val(ui.item.latitude);
jQuery("#longitude").val(ui.item.longitude);
var latitude = jQuery('#latitude').val();
var longitude = jQuery('#longitude').val();
map.setView([latitude,longitude],10);
}
});
//Search on MAP//
});