Skip to content

Commit dbf3a98

Browse files
authored
Merge pull request #160 from alikaakati/master
Fixed markers error on null values
2 parents e3ee2e8 + 6674ec8 commit dbf3a98

File tree

7 files changed

+67
-22
lines changed

7 files changed

+67
-22
lines changed

src/control/content/components/LocationsActionBar.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LocationsActionBar extends React.Component {
2020
onFileChange() {
2121
const file = this.fileInput.files[0];
2222
const reader = new FileReader();
23-
23+
console.log(file);
2424
reader.onload = (e) => {
2525
const rows = csv.parse(e.target.result).slice(1);
2626
const { places } = this.props;
@@ -42,6 +42,7 @@ class LocationsActionBar extends React.Component {
4242
description,
4343
image,
4444
] = row;
45+
console.log(locations);
4546
const selectedCategory = [];
4647

4748
const cat = Number.isInteger(categories)
@@ -134,6 +135,8 @@ class LocationsActionBar extends React.Component {
134135
if (!promises.length) {
135136
while (locations.length) {
136137
let paginatedLocations = locations.splice(0, 500);
138+
console.log("paginated locations");
139+
console.log(paginatedLocations[0]);
137140
this.props.onMultipleSubmit(paginatedLocations);
138141
}
139142
} else {
@@ -143,6 +146,8 @@ class LocationsActionBar extends React.Component {
143146
window.locs = locs;
144147
while (locs.length) {
145148
let paginatedLocations = locs.splice(0, 500);
149+
console.log("paginated locations");
150+
console.log(paginatedLocations);
146151
this.props.onMultipleSubmit(paginatedLocations);
147152
}
148153
});
@@ -289,6 +294,7 @@ class LocationsActionBar extends React.Component {
289294
)}
290295
</div>
291296
</div>
297+
292298
<div className="col-xs-8">
293299
<input
294300
onChange={() => this.onFileChange()}

src/control/content/content.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ class Content extends React.Component {
490490
* @param {Object} locations Locations array
491491
*/
492492
onMultipleLocationSubmit(locations) {
493+
493494
locations = locations.filter((location) => typeof location === "object");
494495
let locationsForUpdate = [];
495496
let locationsForInsert = [];
@@ -520,13 +521,46 @@ class Content extends React.Component {
520521
console.error(err);
521522
} else if (result && result.data && result.data.length) {
522523
const newDataCount = result.data.length;
524+
523525
for (let skip = 0; skip < newDataCount; skip += 50) {
524526
buildfire.datastore.search(
525-
{ filter: {}, skip, limit: 50 },
527+
{ filter: {}, skip, limit: 50, sort:{createdOn : -1} },
526528
"places-list",
527529
(err, innerResult) => {
528530
if (err) return;
531+
529532
innerResult.forEach((item) => {
533+
console.log("GOING TO ADD TO SEARCH ENGINE");
534+
if(item && item.id && item.data.title){
535+
let insertData = {
536+
tag: "place-data",
537+
title: item.data.title,
538+
description: item.data.description ? item.data.description.replace(/(<([^>]+)>)/gi, "") : "",
539+
imageUrl: item.data.image ? item.data.image : "",
540+
keywords: item.data.subtitle ? item.data.subtitle : "",
541+
data: {
542+
placeId: item.id,
543+
},
544+
};
545+
546+
547+
SearchEngine.insert(insertData, (callbackData) => {
548+
console.log(callbackData);
549+
});
550+
551+
552+
}
553+
554+
555+
556+
557+
558+
559+
560+
561+
562+
563+
530564
Deeplink.getById(item.id, (err, locationDeeplink) => {
531565
if (!err && locationDeeplink) {
532566
locationDeeplink.name = item.data.title

src/widget/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta name="viewport" content="width=device-width,initial-scale=1">
55
<meta charset="utf-8">
6-
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOp1GltsWARlkHhF1H_cb6xtdR1pvNDAk"></script>
6+
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOp1GltsWARlkHhF1H_cb6xtdR1pvNDAk&sensor=false"></script>
77
<script src="../../../scripts/_bundles/buildfire_lightcarousel.min.js"></script>
88
<link rel="stylesheet" href="https://cdn.quilljs.com/1.0.0/quill.snow.css"/>
99
<script src="../../../scripts/buildfire/components/toast/toast.js"></script>

src/widget/js/map.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Handlebars from "./lib/handlebars"
2-
32
import { stringsConfig } from "../js/shared/stringsConfig";
43
import "../js/shared/strings";
54

@@ -166,6 +165,7 @@ window.mapView = {
166165
};
167166

168167
// Add a marker clusterer to manage the markers.
168+
console.log("is error from here");
169169
mapView.settings.markerClusterer = new MarkerClusterer(map, app.state.markers, clusterOptions);
170170

171171
},
@@ -222,22 +222,24 @@ window.mapView = {
222222
});
223223
}
224224
if (skip) return;
225-
let marker = new google.maps.Marker({
226-
position: place.address,
227-
markerData: place,
228-
map: map,
229-
icon: mapView.createMarker(iconType)
230-
});
231-
232-
if(place.address){
233-
let lat = place.address.lat,
234-
lng = place.address.lng;
235-
236-
app.state.markers.push(marker);
237-
app.state.bounds.extend({lat, lng});
238-
if (mapView.settings.markerClusterer) mapView.settings.markerClusterer.addMarker(marker);
239-
240-
marker.addListener('click', () => {mapView.markerClick(place, marker)});
225+
if(place && place.address && place.address.lat && place.address.lng){
226+
let marker = new google.maps.Marker({
227+
position: place.address,
228+
markerData: place,
229+
map: map,
230+
icon: mapView.createMarker(iconType)
231+
});
232+
233+
if(place.address){
234+
let lat = place.address.lat,
235+
lng = place.address.lng;
236+
237+
app.state.markers.push(marker);
238+
app.state.bounds.extend({lat, lng});
239+
if (mapView.settings.markerClusterer) mapView.settings.markerClusterer.addMarker(marker);
240+
241+
marker.addListener('click', () => {mapView.markerClick(place, marker)});
242+
}
241243
}
242244
},
243245
markerClick: (place, marker) => {
@@ -389,5 +391,6 @@ window.mapView = {
389391

390392
window.originalHeight = (app.views.mapView) ? app.views.mapView.getBoundingClientRect().height: 0;
391393

392-
}
394+
},
395+
393396
};

src/widget/js/shared/Deeplink.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export default class Deeplink {
2424
console.error(err, '<<< ERROR WHILE REGISTERING DEEP LINK.');
2525
return callback(err);
2626
}
27-
2827
callback(null, {
2928
deeplinkId: result && result.data && result.data.deeplinkId ? result.data.deeplinkId : null,
3029
deeplinkData: new Deeplink(result && result.data ? result.data : null)

src/widget/list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
<div class="listViewFilter" id="filter"></div>
2+
<div style="padding: 20px;">
3+
</div>

src/widget/map.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
<div id="googleMap" style="height:100%;width:100%;position:absolute;"></div>
33
<div class="mapCenter" id="mapCenter"></div>
44
<div class="listViewFilter" id="mapFilter"></div>
5+

0 commit comments

Comments
 (0)