Make price filtering work
This commit is contained in:
@@ -82,37 +82,7 @@ class Main extends React.Component {
|
||||
this.map = map;
|
||||
|
||||
map.addListener('idle', () => {
|
||||
const properties = loadProperties({
|
||||
bounds: map.getBounds().toUrlValue(),
|
||||
minPrice: this.state.filters.minPrice});
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
})
|
||||
this.refreshListings();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -128,6 +98,44 @@ class Main extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
refreshListings() {
|
||||
const map = this.map;
|
||||
const properties = loadProperties({
|
||||
bounds: map.getBounds().toUrlValue(),
|
||||
minPrice: this.state.filters.minPrice,
|
||||
maxPrice: this.state.filters.maxPrice,
|
||||
rooms: this.state.filters.rooms
|
||||
});
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
onListingClick() {
|
||||
this.setState({
|
||||
listingDetails: true
|
||||
|
||||
Reference in New Issue
Block a user