Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit for tweet search (hashtag, user) #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions js/map/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ let base = {
return {
center: base.map.getCenter(),
zoom: base.map.getZoom(),
//ht: url.getHT(),
layers: base.getVisibleLayers(),
tweet: tweets.activeTweet,
}
Expand Down
55 changes: 40 additions & 15 deletions js/map/tweets.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ let manager = {
manager.data.tweets = data;
// manager.data.tweets = {...manager.data.tweets, ...data.tweets};
// manager.data.date = data.date;
// console.log(manager.data.tweets)
//console.log(manager.data.tweets)
let tweetOpacity = 0.3

Object.keys(manager.data.tweets).forEach((id) => {
Expand All @@ -179,23 +179,48 @@ let manager = {
if (tweetInfo.hashtags.includes('private') || tweetInfo.hashtags.includes('hide'))
return;

if (tweetInfo.state.zoom >= 6){
let marker = L.marker(tweetInfo.state.center, {icon: icons['climateaction'], opacity: tweetOpacity})

if(tweetOpacity < 1)
tweetOpacity = tweetOpacity + 0.006
//marker.addTo(manager.clusters)
marker.addTo(base.layerSets.tweets.layers.tweets)
marker.on('click', function () {
manager.show(id)
})
manager.data.tweetIdToMarker[id] = marker
}
else {
return;
//console.log(tweetInfo.state);

//Check URL For hashtag filter
let state = url.getState();

console.log(state.hashtag)
if(state.hashtag){
if (tweetInfo.hashtags.includes(state.hashtag)){
let marker = L.marker(tweetInfo.state.center, {icon: icons['climateaction'], opacity: tweetOpacity})

if(tweetOpacity < 1)
tweetOpacity = tweetOpacity + 0.006
//marker.addTo(manager.clusters)
marker.addTo(base.layerSets.tweets.layers.tweets)
marker.on('click', function () {
manager.show(id)
})
manager.data.tweetIdToMarker[id] = marker
}
else {
return;
}
} else {
if (tweetInfo.state.zoom >= 5){
let marker = L.marker(tweetInfo.state.center, {icon: icons['climateaction'], opacity: tweetOpacity})

if(tweetOpacity < 1)
tweetOpacity = tweetOpacity + 0.006
//marker.addTo(manager.clusters)
marker.addTo(base.layerSets.tweets.layers.tweets)
marker.on('click', function () {
manager.show(id)
})
manager.data.tweetIdToMarker[id] = marker
}
else {
return;
}
}



});
$(manager).trigger('loaded');
})
Expand Down
19 changes: 17 additions & 2 deletions js/map/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let url = {
prefix: '/',
//prefix: '',
keyValueDivider: '=',
specialKeys: ['@'],
specialKeys: ['@', '$'],
listDivider: ',',
divider: '/',
geoHash: true,
Expand All @@ -18,9 +18,11 @@ let url = {

let vars = {
z: s.zoom,
ht: s.hashtag,
ls: layers.join(url.listDivider)
}


if (s.tweet) {
vars = {...{
't': s.tweet,
Expand Down Expand Up @@ -77,6 +79,13 @@ let url = {
if (rs.z)
s.zoom = parseInt(rs.z);

if (rs['$']) {
s.hashtag = rs['$'];
}

if (rs.ht)
s.hashtag = rs.ht;

if (rs.ls)
s.layers = rs.ls.split(url.listDivider);

Expand All @@ -103,9 +112,15 @@ let url = {
return url._urlToState(url.getPath());
},

getHT: function() {
var state = url.getState();
//console.log(state.hashtag)
return state.hashtag;
},

getPath: function() {
return window.location.pathname;
},
}
}

export default url;