var map, featureList,master1Search = [],master1Search = [],master2Search = [],asistantSearch = [],river_masterSearch = [],river_asistantSearch = [],coachSearch = [],wingsurfSearch = [],supyogaSearch = [],yogamasterSearch = []; $(window).resize(function() { sizeLayerControl(); }); $(document).on("click", ".feature-row", function(e) { $(document).off("mouseout", ".feature-row", clearHighlight); sidebarClick(parseInt($(this).attr("id"), 10)); }); if ( !("ontouchstart" in window) ) { $(document).on("mouseover", ".feature-row", function(e) { highlight.clearLayers().addLayer(L.circleMarker([$(this).attr("lat"), $(this).attr("lng")], highlightStyle)); }); } $(document).on("mouseout", ".feature-row", clearHighlight); $("#about-btn").click(function() { $("#aboutModal").modal("show"); $(".navbar-collapse.in").collapse("hide"); return false; }); $("#legend-btn").click(function() { $("#legendModal").modal("show"); $(".navbar-collapse.in").collapse("hide"); return false; }); $("#login-btn").click(function() { $("#loginModal").modal("show"); $(".navbar-collapse.in").collapse("hide"); return false; }); $("#list-btn").click(function() { animateSidebar(); return false; }); $("#nav-btn").click(function() { $(".navbar-collapse").collapse("toggle"); return false; }); $("#sidebar-toggle-btn").click(function() { animateSidebar(); return false; }); $("#sidebar-hide-btn").click(function() { animateSidebar(); return false; }); function animateSidebar() { $("#sidebar").animate({ width: "toggle" }, 350, function() { map.invalidateSize(); }); } function sizeLayerControl() { $(".leaflet-control-layers").css("max-height", $("#map").height() - 50); } function clearHighlight() { highlight.clearLayers(); } function sidebarClick(id) { var layer = markerClusters.getLayer(id); map.setView([layer.getLatLng().lat, layer.getLatLng().lng], 17); layer.fire("click"); /* Hide sidebar and go to the map on small screens */ if (document.body.clientWidth <= 767) { $("#sidebar").hide(); map.invalidateSize(); } } function syncSidebar() { /* Empty sidebar features */ $("#feature-list tbody").empty(); /* Loop through layer and add only features which are in the map bounds */ master1s.eachLayer(function (layer) {if (map.hasLayer(master1Layer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});master1s.eachLayer(function (layer) {if (map.hasLayer(master1Layer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});master2s.eachLayer(function (layer) {if (map.hasLayer(master2Layer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});asistants.eachLayer(function (layer) {if (map.hasLayer(asistantLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});river_masters.eachLayer(function (layer) {if (map.hasLayer(river_masterLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});river_asistants.eachLayer(function (layer) {if (map.hasLayer(river_asistantLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});coachs.eachLayer(function (layer) {if (map.hasLayer(coachLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});wingsurfs.eachLayer(function (layer) {if (map.hasLayer(wingsurfLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});supyogas.eachLayer(function (layer) {if (map.hasLayer(supyogaLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}});yogamasters.eachLayer(function (layer) {if (map.hasLayer(yogamasterLayer)) {if (map.getBounds().contains(layer.getLatLng())) {$("#feature-list tbody").append('' + layer.feature.properties.NAME + '');}}}); /* Update list.js featureList */ featureList = new List("features", { valueNames: ["feature-name"] }); featureList.sort("feature-name", { order: "asc" }); } /* Basemap Layers */ var cartoLight = L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png", { maxZoom: 19, attribution: '© OpenStreetMap contributors, © CartoDB' }); var usgsImagery = L.layerGroup([L.tileLayer("http://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}", { maxZoom: 15, }), L.tileLayer.wms("http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_SCALE/ImageServer/WMSServer?", { minZoom: 16, maxZoom: 19, layers: "0", format: 'image/jpeg', transparent: true, attribution: "Aerial Imagery courtesy USGS" })]); /* Overlay Layers */ var highlight = L.geoJson(null); var highlightStyle = { stroke: false, fillColor: "#00FFFF", fillOpacity: 0.7, radius: 10 }; /* Single marker cluster layer to hold all clusters */ var markerClusters = new L.MarkerClusterGroup({ spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true, disableClusteringAtZoom: 16 }); var master1Layer = L.geoJson(null); var master1s = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/master1.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); master1Search.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Master1s", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/master1.php", function (data) { master1s.addData(data); map.addLayer(master1Layer);});var master1Layer = L.geoJson(null); var master1s = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/master1.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); master1Search.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Master1s", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/master1.php", function (data) { master1s.addData(data); map.addLayer(master1Layer);});var master2Layer = L.geoJson(null); var master2s = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/master2.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); master2Search.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Master2s", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/master2.php", function (data) { master2s.addData(data); map.addLayer(master2Layer);});var asistantLayer = L.geoJson(null); var asistants = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/asistant.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); asistantSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Asistants", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/asistant.php", function (data) { asistants.addData(data); map.addLayer(asistantLayer);});var river_masterLayer = L.geoJson(null); var river_masters = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/river_master.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); river_masterSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "River_masters", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/river_master.php", function (data) { river_masters.addData(data); map.addLayer(river_masterLayer);});var river_asistantLayer = L.geoJson(null); var river_asistants = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/river_asistant.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); river_asistantSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "River_asistants", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/river_asistant.php", function (data) { river_asistants.addData(data); map.addLayer(river_asistantLayer);});var coachLayer = L.geoJson(null); var coachs = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/coach.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); coachSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Coachs", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/coach.php", function (data) { coachs.addData(data); map.addLayer(coachLayer);});var wingsurfLayer = L.geoJson(null); var wingsurfs = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/wingsurf.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); wingsurfSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Wingsurfs", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/wingsurf.php", function (data) { wingsurfs.addData(data); map.addLayer(wingsurfLayer);});var supyogaLayer = L.geoJson(null); var supyogas = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/supyoga.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); supyogaSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Supyogas", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/supyoga.php", function (data) { supyogas.addData(data); map.addLayer(supyogaLayer);});var yogamasterLayer = L.geoJson(null); var yogamasters = L.geoJson(null, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconUrl: "img/yogamaster.png", iconSize: [24, 28], iconAnchor: [12, 28], popupAnchor: [0, -25] }), title: feature.properties.NAME, riseOnHover: true }); }, onEachFeature: function (feature, layer) { if (feature.properties) { var content = "
' + layer.feature.properties.NAME + '
" + "" + "" + "" + "" + "
Nombre" + feature.properties.NAME + "
Contacto" + feature.properties.TEL + " " + feature.properties.EMAIL + "
Tipo" + feature.properties.TYPE + "
+ info
"; layer.on({ click: function (e) { $("#feature-title").html(feature.properties.NAME); $("#feature-info").html(content); $("#featureModal").modal("show"); highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); } }); $("#feature-list tbody").append(''); yogamasterSearch.push({ name: layer.feature.properties.NAME, address: layer.feature.properties.ADDRESS1, source: "Yogamasters", id: L.stamp(layer), lat: layer.feature.geometry.coordinates[1], lng: layer.feature.geometry.coordinates[0] }); } } }); $.getJSON("data/yogamaster.php", function (data) { yogamasters.addData(data); map.addLayer(yogamasterLayer);}); map = L.map("map", { zoom: 2, center: [35.729569, -8.723145], layers: [cartoLight, markerClusters, highlight], zoomControl: true, attributionControl: false }); /* Layer control listeners that allow for a single markerClusters layer */ map.on("overlayadd", function(e) { if (e.layer === master1Layer) {markerClusters.addLayer(master1s);syncSidebar();}if (e.layer === master1Layer) {markerClusters.addLayer(master1s);syncSidebar();}if (e.layer === master2Layer) {markerClusters.addLayer(master2s);syncSidebar();}if (e.layer === asistantLayer) {markerClusters.addLayer(asistants);syncSidebar();}if (e.layer === river_masterLayer) {markerClusters.addLayer(river_masters);syncSidebar();}if (e.layer === river_asistantLayer) {markerClusters.addLayer(river_asistants);syncSidebar();}if (e.layer === coachLayer) {markerClusters.addLayer(coachs);syncSidebar();}if (e.layer === wingsurfLayer) {markerClusters.addLayer(wingsurfs);syncSidebar();}if (e.layer === supyogaLayer) {markerClusters.addLayer(supyogas);syncSidebar();}if (e.layer === yogamasterLayer) {markerClusters.addLayer(yogamasters);syncSidebar();} }); map.on("overlayremove", function(e) { if (e.layer === master1Layer) {markerClusters.removeLayer(master1s);syncSidebar();}if (e.layer === master1Layer) {markerClusters.removeLayer(master1s);syncSidebar();}if (e.layer === master2Layer) {markerClusters.removeLayer(master2s);syncSidebar();}if (e.layer === asistantLayer) {markerClusters.removeLayer(asistants);syncSidebar();}if (e.layer === river_masterLayer) {markerClusters.removeLayer(river_masters);syncSidebar();}if (e.layer === river_asistantLayer) {markerClusters.removeLayer(river_asistants);syncSidebar();}if (e.layer === coachLayer) {markerClusters.removeLayer(coachs);syncSidebar();}if (e.layer === wingsurfLayer) {markerClusters.removeLayer(wingsurfs);syncSidebar();}if (e.layer === supyogaLayer) {markerClusters.removeLayer(supyogas);syncSidebar();}if (e.layer === yogamasterLayer) {markerClusters.removeLayer(yogamasters);syncSidebar();} }); /* Filter sidebar feature list to only show features in current map bounds */ map.on("moveend", function (e) { syncSidebar(); }); /* Clear feature highlight when map is clicked */ map.on("click", function(e) { highlight.clearLayers(); }); /* GPS enabled geolocation control set to follow the user's location */ var locateControl = L.control.locate({ position: "bottomright", drawCircle: true, follow: true, setView: true, keepCurrentZoomLevel: true, markerStyle: { weight: 1, opacity: 0.8, fillOpacity: 0.8 }, circleStyle: { weight: 1, clickable: false }, icon: "fa fa-location-arrow", metric: false, strings: { title: "My location", popup: "You are within {distance} {unit} from this point", outsideMapBoundsMsg: "You seem located outside the boundaries of the map" }, locateOptions: { maxZoom: 18, watch: true, enableHighAccuracy: true, maximumAge: 10000, timeout: 10000 } }).addTo(map); /* Larger screens get expanded layer control and visible sidebar */ if (document.body.clientWidth <= 767) { var isCollapsed = true; } else { var isCollapsed = false; } var baseLayers = { "Mapa base": cartoLight, "Imagen aerea": usgsImagery }; var groupedOverlays = { "Tipos": { " master1": master1Layer," master1": master1Layer," master2": master2Layer," asistant": asistantLayer," river_master": river_masterLayer," river_asistant": river_asistantLayer," coach": coachLayer," wingsurf": wingsurfLayer," supyoga": supyogaLayer," yogamaster": yogamasterLayer } }; var layerControl = L.control.groupedLayers(baseLayers, groupedOverlays, { collapsed: isCollapsed }).addTo(map); /* Highlight search box text on click */ $("#searchbox").click(function () { $(this).select(); }); /* Prevent hitting enter from refreshing the page */ $("#searchbox").keypress(function (e) { if (e.which == 13) { e.preventDefault(); } }); $("#featureModal").on("hidden.bs.modal", function (e) { $(document).on("mouseout", ".feature-row", clearHighlight); }); /* Typeahead search functionality */ $(document).one("ajaxStop", function () { $("#loading").hide(); sizeLayerControl(); featureList = new List("features", {valueNames: ["feature-name"]}); featureList.sort("feature-name", {order:"asc"}); var master1sBH = new Bloodhound({name: "Master1s",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: master1Search,limit: 10});var master1sBH = new Bloodhound({name: "Master1s",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: master1Search,limit: 10});var master2sBH = new Bloodhound({name: "Master2s",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: master2Search,limit: 10});var asistantsBH = new Bloodhound({name: "Asistants",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: asistantSearch,limit: 10});var river_mastersBH = new Bloodhound({name: "River_masters",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: river_masterSearch,limit: 10});var river_asistantsBH = new Bloodhound({name: "River_asistants",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: river_asistantSearch,limit: 10});var coachsBH = new Bloodhound({name: "Coachs",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: coachSearch,limit: 10});var wingsurfsBH = new Bloodhound({name: "Wingsurfs",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: wingsurfSearch,limit: 10});var supyogasBH = new Bloodhound({name: "Supyogas",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: supyogaSearch,limit: 10});var yogamastersBH = new Bloodhound({name: "Yogamasters",datumTokenizer: function (d) {return Bloodhound.tokenizers.whitespace(d.name);},queryTokenizer: Bloodhound.tokenizers.whitespace,local: yogamasterSearch,limit: 10}); var geonamesBH = new Bloodhound({ name: "GeoNames", datumTokenizer: function (d) { return Bloodhound.tokenizers.whitespace(d.name); }, queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { url: "http://api.geonames.org/searchJSON?username=bootleaf&featureClass=P&maxRows=5&countryCode=US&name_startsWith=%QUERY", filter: function (data) { return $.map(data.geonames, function (result) { return { name: result.name + ", " + result.adminCode1, lat: result.lat, lng: result.lng, source: "GeoNames" }; }); }, ajax: { beforeSend: function (jqXhr, settings) { settings.url += "&east=" + map.getBounds().getEast() + "&west=" + map.getBounds().getWest() + "&north=" + map.getBounds().getNorth() + "&south=" + map.getBounds().getSouth(); $("#searchicon").removeClass("fa-search").addClass("fa-refresh fa-spin"); }, complete: function (jqXHR, status) { $('#searchicon').removeClass("fa-refresh fa-spin").addClass("fa-search"); } } }, limit: 10 }); master1sBH.initialize();master1sBH.initialize();master2sBH.initialize();asistantsBH.initialize();river_mastersBH.initialize();river_asistantsBH.initialize();coachsBH.initialize();wingsurfsBH.initialize();supyogasBH.initialize();yogamastersBH.initialize(); geonamesBH.initialize(); /* instantiate the typeahead UI */ $("#searchbox").typeahead({ minLength: 3, highlight: true, hint: false }, {name: "Master1s",displayKey: "name",source: master1sBH.ttAdapter(),templates: {header: "

 master1s

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Master1s",displayKey: "name",source: master1sBH.ttAdapter(),templates: {header: "

 master1s

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Master2s",displayKey: "name",source: master2sBH.ttAdapter(),templates: {header: "

 master2s

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Asistants",displayKey: "name",source: asistantsBH.ttAdapter(),templates: {header: "

 asistants

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "River_masters",displayKey: "name",source: river_mastersBH.ttAdapter(),templates: {header: "

 river_masters

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "River_asistants",displayKey: "name",source: river_asistantsBH.ttAdapter(),templates: {header: "

 river_asistants

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Coachs",displayKey: "name",source: coachsBH.ttAdapter(),templates: {header: "

 coachs

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Wingsurfs",displayKey: "name",source: wingsurfsBH.ttAdapter(),templates: {header: "

 wingsurfs

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Supyogas",displayKey: "name",source: supyogasBH.ttAdapter(),templates: {header: "

 supyogas

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}},{name: "Yogamasters",displayKey: "name",source: yogamastersBH.ttAdapter(),templates: {header: "

 yogamasters

",suggestion: Handlebars.compile(["{{name}}
 {{address}}"].join(""))}}, { name: "GeoNames", displayKey: "name", source: geonamesBH.ttAdapter(), templates: { header: "

 GeoNames

" } }).on("typeahead:selected", function (obj, datum) { if (datum.source === "Master1s") {if (!map.hasLayer(master1Layer)) {map.addLayer(master1Layer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Master1s") {if (!map.hasLayer(master1Layer)) {map.addLayer(master1Layer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Master2s") {if (!map.hasLayer(master2Layer)) {map.addLayer(master2Layer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Asistants") {if (!map.hasLayer(asistantLayer)) {map.addLayer(asistantLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "River_masters") {if (!map.hasLayer(river_masterLayer)) {map.addLayer(river_masterLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "River_asistants") {if (!map.hasLayer(river_asistantLayer)) {map.addLayer(river_asistantLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Coachs") {if (!map.hasLayer(coachLayer)) {map.addLayer(coachLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Wingsurfs") {if (!map.hasLayer(wingsurfLayer)) {map.addLayer(wingsurfLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Supyogas") {if (!map.hasLayer(supyogaLayer)) {map.addLayer(supyogaLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} }if (datum.source === "Yogamasters") {if (!map.hasLayer(yogamasterLayer)) {map.addLayer(yogamasterLayer);}map.setView([datum.lat, datum.lng], 17);if (map._layers[datum.id]) {map._layers[datum.id].fire("click");} } if (datum.source === "GeoNames") { map.setView([datum.lat, datum.lng], 14); } if ($(".navbar-collapse").height() > 50) { $(".navbar-collapse").collapse("hide"); } }).on("typeahead:opened", function () { $(".navbar-collapse.in").css("max-height", $(document).height() - $(".navbar-header").height()); $(".navbar-collapse.in").css("height", $(document).height() - $(".navbar-header").height()); }).on("typeahead:closed", function () { $(".navbar-collapse.in").css("max-height", ""); $(".navbar-collapse.in").css("height", ""); }); $(".twitter-typeahead").css("position", "static"); $(".twitter-typeahead").css("display", "block"); }); // Leaflet patch to make layer control scrollable on touch browsers var container = $(".leaflet-control-layers")[0]; if (!L.Browser.touch) { L.DomEvent .disableClickPropagation(container) .disableScrollPropagation(container); } else { L.DomEvent.disableClickPropagation(container); }
' + layer.feature.properties.NAME + '