Progress on filters

This commit is contained in:
Edin Dazdarevic
2017-04-05 00:14:30 +02:00
parent 49e9e2fdfb
commit d2ee02b6df
14 changed files with 395 additions and 164 deletions

View File

@@ -14,7 +14,6 @@ class Main extends React.Component {
listings: (new Map()),
imageIndex: 0,
filters: {
minPrice: 0,
rooms: {}
}
};
@@ -100,40 +99,44 @@ class Main extends React.Component {
refreshListings() {
const map = this.map;
const {rooms, minSize, maxSize, minPrice, maxPrice} = this.state.filters;
const properties = loadProperties({
bounds: map.getBounds().toUrlValue(),
minPrice: this.state.filters.minPrice,
maxPrice: this.state.filters.maxPrice,
rooms: this.state.filters.rooms
rooms,
minSize,
maxSize,
minPrice,
maxPrice
});
properties.then(p=> p.text()).then(p => {
const data = JSON.parse(p);
console.log('props', data)
for(const [index, prop] of data.entries()) {
const myLatLng = {lat: prop.loc[0], lng: prop.loc[1]};
properties.then(p=> p.text()).then(p => {
const data = JSON.parse(p);
console.log('props', data)
for(const [index, prop] of data.entries()) {
const myLatLng = {lat: prop.loc[0], lng: prop.loc[1]};
const marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: prop.title
});
marker.addListener('click', () => {
console.log('clicking...')
this.dispatch({type: 'VIEW_LISTING_DETAILS', action: {
id: prop.url
}})
});
}
this.dispatch({
type: 'LISTINGS_LOADED',
action: {
listings: data
}
const marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: prop.title
});
})
marker.addListener('click', () => {
console.log('clicking...')
this.dispatch({type: 'VIEW_LISTING_DETAILS', action: {
id: prop.url
}})
});
}
this.dispatch({
type: 'LISTINGS_LOADED',
action: {
listings: data
}
});
})
}
onListingClick() {