var beansUrlParameter = function(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } } var getBaseConfig = function(urlFromRequest) { return { address: '', useGroundElevation: false, elevation: 0, canonicalUrl: urlFromRequest }; } var convertUnitsArr2 = function(address, unitsArr, hideMarkers) { var convertedArr = []; for (var i = 0; i < unitsArr.length; i++) { var bedText = unitsArr[i].bed ? (unitsArr[i].bed + ' Bed') : 'Studio'; var td = new Date().toISOString().substring(0, 10); var as = (unitsArr[i].availability ? ('on ' + unitsArr[i].availability) : 'Now'); if (unitsArr[i].availability && unitsArr[i].availability <= td) { as = 'Now'; } var onPreviewData; if (unitsArr.floorplanImg) { onPreviewData = [ { value: bedText + ' / ' + unitsArr[i].bath + ' Bath / ' + (unitsArr[i].sqft ? unitsArr[i].sqft.toLocaleString() : '0') + ' sq. ft.' }, { value: 'img:' + unitsArr[i].floorplanImg }, { value: '$' + (unitsArr[i].rent ? unitsArr[i].rent.toLocaleString() : '0') + '/ mo' }, { value: 'Available ' + as } ]; } else { onPreviewData = [ { value: bedText + ' / ' + unitsArr[i].bath + ' Bath / ' + (unitsArr[i].sqft ? unitsArr[i].sqft.toLocaleString() : '0') + ' sq. ft.' }, { value: '$' + (unitsArr[i].rent ? unitsArr[i].rent.toLocaleString() : '0') + '/ mo' }, { value: 'Available ' + as } ]; } convertedArr.push({ address: address, unit: unitsArr[i].unit, options: { markers: { display: hideMarkers ? false : true }, poi: [ { name: "ALL", display: false }, { name: "CLUBHOUSE", display: true }, { name: "SWIMMINGPOOL", display: true }, { name: "OFFICE", display: true }, { name: "GYM", display: true }, { name: "MAILROOM", display: true }, { name: "LAUNDRY", display: true }, { name: "PLAYGROUND", display: true } ], onPreviewData: onPreviewData, onClickData: { name: unitsArr[i].unit ? unitsArr[i].unit.replaceAll('||', ' - ') : '', bed: unitsArr[i].bed, bath: unitsArr[i].bath, sqft: unitsArr[i].sqft, rent: unitsArr[i].rent, floorplanImg: unitsArr[i].floorplanImg, availability: unitsArr[i].availability, link: unitsArr[i].link ? unitsArr[i].link.replaceAll('&', '&') : '' } } }); } return convertedArr; } var convertUnitsArr = function(config, unitsArr, hideMarkers, skipSort) { var addressAndUnitWithOptions; if (unitsArr.length === 0) { unitsArr.push({ unit: '' }); addressAndUnitWithOptions = convertUnitsArr2(config.address, unitsArr, hideMarkers); addressAndUnitWithOptions[0].isPlaceHolder = true; } else { if (!skipSort) { unitsArr.sort((a, b) => { var aa = a.unit ? a.unit : ''; var bb = b.unit ? b.unit : ''; return aa.localeCompare(bb); }); } addressAndUnitWithOptions = convertUnitsArr2(config.address, unitsArr, hideMarkers); } if (config.unitShapeConfig) { for (var i = 0; i < addressAndUnitWithOptions.length; i++) { addressAndUnitWithOptions[i].options.unitShape = config.unitShapeConfig(addressAndUnitWithOptions[i]); } } if (config.poi) { for (var i = 0; i < addressAndUnitWithOptions.length; i++) { for (var j = 0; j < config.poi.length; j++) { addressAndUnitWithOptions[i].options.poi.push(config.poi[j]); } } } return addressAndUnitWithOptions; } var commonImmersives = [ { url: "https://gis-server.beans.ai/arcgis/rest/services/Hosted/Immersive_Layers/FeatureServer/0", elevationInfo: { mode: "absolute-height", offset: 0.5, }, renderer: { type: "unique-value", field: "type", uniqueValueInfos: [ { value: "Apricot", symbol: { type: "web-style", name: "Prunus", styleName: "EsriRealisticTreesStyle" } }, { value: "Mountain Mahogany", symbol: { type: "web-style", name: "Cercocarpus", styleName: "EsriRealisticTreesStyle" } }, { value: "Rose", symbol: { type: "web-style", name: "Rosa", styleName: "EsriRealisticTreesStyle" } } ] }, isFeature: true }, { url: "https://gis-server.beans.ai/arcgis/rest/services/Hosted/Immersive_Layers/FeatureServer/1", elevationInfo: { mode: "absolute-height", offset: 0.5, }, renderer: { type: "unique-value", field: "type", uniqueValueInfos: [ { value: "Walkway", symbol: { type: "simple-line", width: 4, color: "#fcf5de" } }, { value: "Road", symbol: { type: "simple-line", width: 16, color: "#eeeeee" } } ] }, isFeature: true }, { url: "https://gis-server.beans.ai/arcgis/rest/services/Hosted/Immersive_Layers/FeatureServer/2", elevationInfo: { mode: "absolute-height", offset: 0.5, }, renderer: { type: "unique-value", field: "type", uniqueValueInfos: [ { value: "Lawn", symbol: { type: "simple-fill", outline: { width: 0 }, color: "#b2c388" } } ] }, isFeature: true }, { url: "https://gis-server.beans.ai/arcgis/rest/services/Hosted/Immersive_Layers/FeatureServer/2", elevationInfo: { mode: "absolute-height", offset: 1.0, }, renderer: { type: "unique-value", field: "type", uniqueValueInfos: [ { value: "Water", symbol: { type: "simple-fill", outline: { width: 0 }, color: "#a5c2d1" } } ] }, isFeature: true }, ]; var getDisplayOptions = function( config, unitShape_, // Default shape selectedUnitShape_, // Selected shape selectableUnitShape_, // Selectable shape hoverUnitShape_ ) { return { propertyAddress: config.address, offsetGroundElevation: config.elevation, useGroundElevation: config.useGroundElevation, showUnitList: true, showUnitShape: true, showDirections: false, showPath: false, camera: config.camera, mobileCamera: config.mobileCamera, renameAmenities: config.renameAmenities ? config.renameAmenities : null, shadowModeUnitShape: config.shadowModeUnitShape ? config.shadowModeUnitShape : { fillColor: '#ffffff', fillOpacity: 1.0, }, neighborModeUnitShape: config.neighborModeUnitShape ? config.neighborModeUnitShape : { fillColor: '#D8D7D4', fillOpacity: 1.0, }, unitShape: config.unitShape ? config.unitShape : { fillColor: '#DDE3E0', fillOpacity: 1.0, strokeWeight: 1.0, strokeOpacity: 0.5, strokeColor: '#000000', ...unitShape_ }, selectedUnitShape: config.selectedUnitShape ? config.selectedUnitShape : { fillColor: '#A6671D', fillOpacity: 1.0, strokeWeight: 1.0, strokeOpacity: 1.0, strokeColor: '#ffffff', ...selectedUnitShape_ }, selectableUnitShape: config.selectableUnitShape ? config.selectableUnitShape : { fillColor: '#24453E', fillOpacity: 1.0, strokeWeight: 1.0, strokeOpacity: 1.0, strokeColor: '#ffffff', ...selectableUnitShape_ }, satelliteModeUnitShape: config.satelliteModeUnitShape ? config.satelliteModeUnitShape : { fillColor: '#ffffff', fillOpacity: 1.0, }, neighborShape: config.neighborShape, immersiveModeUnitShape: config.immersiveModeUnitShape, poiShape: config.poiShape, hoverUnitShape: hoverUnitShape_ ? hoverUnitShape_ : null, // mobileUnitShape: { // fillColor: '#ffffff', // fillOpacity: 0.2, // strokeWeight: 0.5, // strokeOpacity: 0.2, // strokeColor: '#000000', // } }; } var BeansPontis = function() { }; BeansPontis.prototype.getConfigFromUrl = function(urlFromRequest) { var canonicalUrl = urlFromRequest ? urlFromRequest : window.location.hostname; if (beansUrlParameter('canonicalUrl')) { canonicalUrl = beansUrlParameter('canonicalUrl'); } var baseConfig = getBaseConfig(canonicalUrl); var config = {}; config["www.meridianobici.com"] = { camera: {tilt: 62.4218003933161, heading: 333.98587425865753, position: {x: -76.58118844016079, y: 36.75361461231741, z: 173.05399123113602}}, address: "1000 Meridian Obici Way, Suffolk, VA", prettyLayer: 'https://beans.maps.arcgis.com/sharing/rest/content/items/6465974adfdb437c8423881400b8517d/resources/styles/root.json?f=pjson', showImmersive: true, showImmersiveLight: true, showImmersiveOnLoad: true, immersiveConfig: [ { url: 'https://tiles.arcgis.com/tiles/ob6JNU9Q3wDJysjr/arcgis/rest/services/1000_Meridian_Obici_Way_Suffolk_VA_units_surroundings_roads15/SceneServer', elevationInfo: { mode: "absolute-height", offset: 0.5, } }, { url: 'https://tiles.arcgis.com/tiles/ob6JNU9Q3wDJysjr/arcgis/rest/services/1000_Meridian_Obici_Way_Suffolk_VA_amentities/SceneServer', elevationInfo: { mode: "absolute-height", offset: 0.5, } }, ...commonImmersives, { url: 'https://tiles.arcgis.com/tiles/ob6JNU9Q3wDJysjr/arcgis/rest/services/1000_Units_1/SceneServer', elevationInfo: { mode: "absolute-height", offset: 0.5, }, immersiveType: 'units' } ], }; config['localhost'] = config['www.meridianobici.com']; config['www.beans.ai'] = config['www.meridianobici.com']; if (config[canonicalUrl]) { return {...baseConfig, ...config[canonicalUrl]}; } return baseConfig; } BeansPontis.prototype.getFloorPlans = function(callback) { var so = this; var canonicalUrl = so.getConfigFromUrl().canonicalUrl; var DONE = 4; // readyState 4 means the request is done. var OK = 200; // status 200 is a successful return. var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://' + canonicalUrl + '/floorplans', false); xhr.send(); if (xhr.readyState !== DONE || xhr.status !== OK) { return; } var c = xhr.responseText.split('\n'); var floorplansData = []; var imgs = []; var lastKnownImage = ''; for (var i in c) { var j = c[i]; var y = /.*Floor Plan.*?card-img-top.*?src="(.*?)".*/.exec(j); if (y) { lastKnownImage = y[1]; } if (!y) { y = /.*src="(.*?)".*?card-img-top.*/.exec(j); if (y) { lastKnownImage = y[1]; } } if (!y) { y = /.*data-selenium-id="Floorplan.*?data-src="(http.*?)".*/.exec(j); if (y) { lastKnownImage = y[1]; } } var y = /.*a href="(.*?)".*floorplan-action-button.*/.exec(j); if (y) { floorplansData.push( { url: y[1], img: lastKnownImage, units: [] } ); lastKnownImage = ''; } } var d = c.join(''); var y = /.*(."@context":.*?)}<\/script>.*/.exec(d); if (y) { var z = '{' + y[1] + '}'; var jo = JSON.parse(z); for (var j = 0; j < jo['accommodationFloorPlan'].length; j++) { floorplansData[j].beds = jo['accommodationFloorPlan'][j]['numberOfBedrooms']; floorplansData[j].baths = jo['accommodationFloorPlan'][j]['numberOfFullBathrooms']; } } for (var i = 0; i < floorplansData.length; i++) { var xhr = new XMLHttpRequest(); xhr.open('GET', floorplansData[i].url, false); xhr.send(); if (xhr.readyState !== DONE || xhr.status !== OK) { continue; } var c = xhr.responseText.split('\n'); var z = []; for (var k in c) { var j = c[k]; if (j.indexOf('"url":') !== -1) { mainUrl = j.replaceAll('"url": "', '').replaceAll('"', '').trim(); } var y = /.*type="button".*?id="(.*?)".*?applyGAClick.(.*?)." href="(.*?)".*/.exec(j); if (y) { floorplansData[i].units.push({ unit: y[1], data: y[2], link: y[3] }); } } } var data = new FormData(); data.append('url', canonicalUrl); data.append('unit', JSON.stringify(floorplansData)); var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://www.beans.ai/mapswidget/client/pontis'); xhr.send(data); } BeansPontis.prototype.render = function(be1, addressFromRequest, renderType) { var so = this; var config = so.getConfigFromUrl(); var address = config.address; if (!address) { address = addressFromRequest; } if (beansUrlParameter('getData') === 'true') { so.getFloorPlans(); return; } fetch('https://www.beans.ai/mapswidget/client/pontis-data.json') .then(response => response.json()) .then(json => { var unitsArr = []; for (var i in json) { if (i.indexOf(config.canonicalUrl) !== -1) { var x = JSON.parse(json[i]); for (var j = 0; j < x.length; j++) { for (var k = 0; k < x[j].units.length; k++) { var unit = x[j].units[k]['unit']; var unitData = x[j].units[k]['data']; var y = /.*'(.*)', '(.*)', '(.*)', '(.*)', '(.*)', '(.*)'.*/.exec(unitData); var beds = x[j].beds ? x[j].beds : 0; var baths = x[j].baths ? x[j].baths : 0; var sqft = 0; var rent = 0; floorplanImg = x[j].img ? x[j].img : ''; if (y) { sqft = Number(y[3]); rent = Number(y[4]); } var avail = ''; if (x[j].units[k]['link']) { var ix = x[j].units[k]['link'].lastIndexOf('='); if (ix !== -1) { avail = x[j].units[k]['link'].substring(ix + 1); } } unitsArr.push({ unit: unit, bed: beds, bath: baths, sqft: sqft, rent: rent, link: x[j].units[k]['link'] ,floorplanImg: floorplanImg, availability: avail}); } } } } var addressAndUnitWithOptions = convertUnitsArr(config, unitsArr, true); var displayOptions = getDisplayOptions( config, { fillColor: '#EAD6C3', fillOpacity: 0.2, strokeWeight: 0.5, strokeOpacity: 0.2, strokeColor: '#000000', }, // Default color { fillColor: '#CDA349', }, // Selected color { fillColor: '#3F1F08', } // Selectable color ); if (!renderType || renderType.toLowerCase() === '3d') { be1.render( "body-inner-1", "7f3adbf81e214d9:3434333364636538383264393462646239313262", addressAndUnitWithOptions, { hideNavigateButton: true, hideMyLocationButton: true }, { beansMapType: 'ESRI', initialMap: 'STREET', prettyLayer: config.prettyLayer ? config.prettyLayer : '', // "https://basemaps.arcgis.com/arcgis/rest/services/OpenStreetMap_v2/VectorTileServer" modernButtons: true, modernBeansCard: displayOptions.hideBeansCard ? false : true, outsideButtons: true, showCompass: true, showFullScreenMode: false, showNeighbors: false, showPOIButton: true, showSeparateFacilitiesCard: true, immersiveConfig: config.immersiveConfig, showImmersive: config.showImmersive, showImmersiveLight: config.showImmersiveLight, showImmersiveOnLoad: config.showImmersiveOnLoad, overrideBaseHeightFn: config.overrideBaseHeightFn, overrideHeight: config.overrideHeight ? config.overrideHeight : 0, overrideHeightFn: config.overrideHeightFn, renameAmenities: config.renameAmenities ? config.renameAmenities : null, poiShape: config.poiShape, initialTilt: 30, initialZ: 400, initialHeading: 270, initialPosition: { address: address }, show2DButton: true, event2D: () => { document.getElementById('body-inner-2').style.visibility = 'visible'; document.getElementById('body-inner-1').style.visibility = 'hidden'; }, ...displayOptions } ); } else { if (displayOptions.unitShape) { displayOptions.unitShape.fillOpacity = 1.0; } be1.render( "body-inner-2", "7f3adbf81e214d9:3434333364636538383264393462646239313262", addressAndUnitWithOptions, { hideNavigateButton: true, hideMyLocationButton: true }, { initialMap: "STREET", modernBeansCard: displayOptions.hideBeansCard ? false : true, hideFloorSelector: false, hideRotateControl: true, hideSatelliteButton: true, hideShadow: true, outsideButtons: true, modernButtons: true, showNeighbors: false, showPOIButton: false, showSeparateFacilitiesCard: true, showNumbers: true, numbersConfig: config.numbersConfig, showBuildingShape: config.showBuildingShape, backgroundImage: config.backgroundImage, show3DButton: true, event3D: () => { document.getElementById('body-inner-2').style.visibility = 'hidden'; document.getElementById('body-inner-1').style.visibility = 'visible'; }, unitsToExclude: config.unitsToExclude, ...displayOptions } ); } }); }