var properties = { "data": [ { "id": 1, "title": "Beautiful single home", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": true, "latitude": 51.541599, "longitude": -0.112588, "address": "123 Kathal St. Tampa City, ", "area": 1000, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-1.png", "type_icon": "img/building.png" }, { "id": 2, "title": "Modern Family Home", "price": 2505.11, "listing_for": "Rent", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.538395, "longitude": -0.097418, "address": "123 Kathal St. Tampa City, ", "area": 2500, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-2.png", "type_icon": "img/building.png" }, { "id": 3, "title": "Sweet Family home", "price": 2505.11, "listing_for": "Rent", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": true, "latitude": 51.539212, "longitude": -0.118403, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-3.png", "type_icon": "img/building.png" }, { "id": 4, "title": "Park avenue", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": true, "latitude": 51.522340, "longitude": -0.037894, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-5.png", "type_icon": "img/building.png" }, { "id": 5, "title": "Masons Villas", "price": 2505.11, "listing_for": "Rent", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.513965, "longitude": -0.038837, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-5.png", "type_icon": "img/building.png" }, { "id": 6, "title": "Big Head House", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.503965, "longitude": -0.058837, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-6.png", "type_icon": "img/building.png" }, { "id": 7, "title": "155/A Valley Street 7", "price": 2505.11, "listing_for": "Rent", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.555385, "longitude": -0.128274, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-5.png", "type_icon": "img/building.png" }, { "id": 8, "title": "4552 Lynn Avenue 1", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.560935, "longitude": -0.111365, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-4.png", "type_icon": "img/building.png" }, { "id": 9, "title": "4552 Lynn Avenue 2", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.543803, "longitude": -0.036607, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-3.png", "type_icon": "img/building.png" }, { "id": 10, "title": "4552 Lynn Avenue 3", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.527306, "longitude": -0.140977, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-2.png", "type_icon": "img/building.png" }, { "id": 11, "title": "4552 Lynn Avenue 4", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.558907, "longitude": -0.041842, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-1.png", "type_icon": "img/building.png" }, { "id": 12, "title": "Sweet Family home", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": true, "latitude": 51.550644, "longitude": -0.103493, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-6.png", "type_icon": "img/building.png" }, { "id": 13, "title": "Sweet Family home", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.532112, "longitude": -0.051885, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-5.png", "type_icon": "img/building.png" }, { "id": 14, "title": "4552 Lynn Avenue 7", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": true, "latitude": 51.531311, "longitude": -0.052314, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-4.png", "type_icon": "img/building.png" }, { "id": 15, "title": "Park avenue", "price": 2505.11, "listing_for": "Sale", 'author': 'Jhon Doe', 'date': '5 days ago', "is_featured": false, "latitude": 51.530189, "longitude": -0.078750, "address": "123 Kathal St. Tampa City, ", "area": 2123, "room": 4, "bathroom": 3, "balcony": 3, "lounge": 1, "garage": 1, "image": "img/properties/properties-3.png", "type_icon": "img/building.png" } ] }; function drawInfoWindow(property) { var image = 'img/logo.png'; if (property.image) { image = property.image } var title = 'N/A'; if (property.title) { title = property.title } var address = ''; if (property.address) { address = property.address } var description = 'lorem ipsum dolor sit amet, cfeugiat congue qmper lorem ipsum dolor sit amet'; if (property.description) { description = property.description } var area = 1000; if (property.area) { area = property.area } var Beds = 5; if (property.bedroom) { Beds = property.bedroom } var bathroom = 5; if (property.bathroom) { bathroom = property.bathroom } var garage = 1; if (property.garage) { garage = property.garage } var price = 253.33; if (property.price) { price = property.price } var ibContent = ''; ibContent = "
" + "
" + "" + "
" + "
" + "

" + title + "

" + "

" + address + "

" + "

" + description + "

" + "
" + " " + area + " sqft2 " + " " + Beds + " Bed " + " " + bathroom + " Bath " + " " + garage + " Garages " + "
" + "" + "
"; return ibContent; } function insertPropertyToArray(property, layout) { var image = 'img/logo.png'; if (property.image) { image = property.image } var title = 'N/A'; if (property.title) { title = property.title } var listing_for = 'Sale'; if (property.listing_for) { listing_for = property.listing_for } var address = ''; if (property.address) { address = property.address } var description = 'lorem ipsum dolor sit amet, cfeugiat congue qmper lorem ipsum dolor sit amet'; if (property.description) { description = property.description } var area = 1000; if (property.area) { area = property.area } var Beds = 5; if (property.bedroom) { Beds = property.bedroom } var bathroom = 5; if (property.bathroom) { bathroom = property.bathroom } var garage = 1; if (property.garage) { garage = property.garage } var balcony = 1; if (property.balcony) { balcony = property.balcony } var lounge = 1; if (property.lounge) { lounge = property.lounge } var price = 253.33; if (property.price) { price = property.price } var is_featured = ''; if (property.is_featured) { is_featured = ' '; } var date = ''; if (property.date) { date = property.date; } var author = ''; if (property.author) { author = property.author; } var element = ''; if(layout == 'grid_layout'){ element = '
\n' + ' \n' + '
\n' + is_featured + '
For '+listing_for+'
\n' + '
$'+price+'
\n' + ' fp\n' + '
\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + '
\n' + '
\n' + ' \n' + '
\n' + ' \n' + '
\n' + ' \n' + '

\n' + ' '+title+'\n' + '

\n' + ' \n' + '

\n' + ' \n' + ' '+address+',\n' + ' \n' + '

\n' + ' \n' + '
    \n' + '
  • \n' + ' \n' + ' '+area+' sq ft\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+Beds+' Beds\n' + '
  • \n' + '
  • \n' + ' \n' + ' TV \n' + '
  • \n' + '
  • \n' + ' \n' + ' '+bathroom+' Baths\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+garage+' Garage\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+balcony+' Balcony\n' + '
  • \n' + '
\n' + '
\n' + ' \n' + ' \n' + '
\n' + '
'; '
'; } else{ element = '
\n' + '
\n' + ' \n' + '
\n' + is_featured + '
For '+listing_for+'
\n' + '
$'+price+'
\n' + ' fp-list\n' + '
\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + '
\n' + '
\n' + '
\n' + '
\n' + '
\n' + ' \n' + '

\n' + ' '+title+'\n' + '

\n' + ' \n' + '

\n' + ' \n' + ' '+address+',\n' + ' \n' + '

\n' + ' \n' + '
    \n' + '
  • \n' + ' \n' + ' '+area+' sq ft\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+Beds+' Beds\n' + '
  • \n' + '
  • \n' + ' \n' + ' TV \n' + '
  • \n' + '
  • \n' + ' \n' + ' '+bathroom+' Baths\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+garage+' Garage\n' + '
  • \n' + '
  • \n' + ' \n' + ' '+balcony+' Balcony\n' + '
  • \n' + '
\n' + ' \n' + '
\n' + ' \n' + '
\n' + '
'; } return element; } function animatedMarkers(map, propertiesMarkers, properties, layout) { var bounds = map.getBounds(); var propertiesArray = []; $.each(propertiesMarkers, function (key, value) { if (bounds.contains(propertiesMarkers[key].getLatLng())) { propertiesArray.push(insertPropertyToArray(properties.data[key], layout)); setTimeout(function () { if (propertiesMarkers[key]._icon != null) { propertiesMarkers[key]._icon.className = 'leaflet-marker-icon leaflet-zoom-animated leaflet-clickable bounce-animation marker-loaded'; } }, key * 50); } else { if (propertiesMarkers[key]._icon != null) { propertiesMarkers[key]._icon.className = 'leaflet-marker-icon leaflet-zoom-animated leaflet-clickable'; } } }); $('.fetching-properties').html(propertiesArray); } function generateMap(latitude, longitude, mapProvider, layout) { var map = L.map('map', { center: [latitude, longitude], zoom: 14, scrollWheelZoom: false }); L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); L.tileLayer.provider(mapProvider).addTo(map); var markers = L.markerClusterGroup({ showCoverageOnHover: false, zoomToBoundsOnClick: false }); var propertiesMarkers = []; $.each(properties.data, function (index, property) { var icon = ''; if (property.type_icon) { icon = ''; } var color = ''; var markerContent = '
' + '
' + icon + '
' + '
'; var _icon = L.divIcon({ html: markerContent, iconSize: [36, 46], iconAnchor: [18, 32], popupAnchor: [130, -28], className: '' }); var marker = L.marker(new L.LatLng(property.latitude, property.longitude), { title: property.title, icon: _icon }); propertiesMarkers.push(marker); marker.bindPopup(drawInfoWindow(property)); markers.addLayer(marker); marker.on('popupopen', function () { this._icon.className += ' marker-active'; }); marker.on('popupclose', function () { this._icon.className = 'leaflet-marker-icon leaflet-zoom-animated leaflet-clickable marker-loaded'; }); }); map.addLayer(markers); animatedMarkers(map, propertiesMarkers, properties, layout); map.on('moveend', function () { animatedMarkers(map, propertiesMarkers, properties, layout); }); $('.fetching-properties .property-hover').hover( function () { propertiesMarkers[$(this).attr('id') - 1]._icon.className = 'leaflet-marker-icon leaflet-zoom-animated leaflet-clickable marker-loaded marker-active'; }, function () { propertiesMarkers[$(this).attr('id') - 1]._icon.className = 'leaflet-marker-icon leaflet-zoom-animated leaflet-clickable marker-loaded'; } ); $('.geolocation').on("click", function () { map.locate({setView: true}) }); $('#map').removeClass('fade-map'); }