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

Distinguish between source and destination on the map #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions client/coffee/honeymap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class Honeymap
label.append(Honeymap.eventCountSummary(@hits.region[code]))
onMarkerLabelShow: (ev, label, code) =>
label.html(@captions[code])
label.append(Honeymap.eventCountSummary(@hits.marker[code]))
if @hits.marker[code]["dst"]?
label.append(Honeymap.eventCountSummary(@hits.marker[code]["dst"], "dst"))
label.append(Honeymap.eventCountSummary(@hits.marker[code]["src"], "src"))
else
label.append(Honeymap.eventCountSummary(@hits.marker[code]["src"]))
)
@mapObj = @mapElem.vectorMap('get', 'mapObject')
@mapObj.regions['US'].config.name = "USA"
Expand Down Expand Up @@ -78,8 +82,9 @@ class Honeymap

incMarkerCount: (marker) ->
@hits.marker[marker.id()] ||= {}
@hits.marker[marker.id()][marker.eventName] ||= 0
@hits.marker[marker.id()][marker.eventName]++
@hits.marker[marker.id()][marker.type] ||= {}
@hits.marker[marker.id()][marker.type][marker.eventName] ||= 0
@hits.marker[marker.id()][marker.type][marker.eventName]++
# only count src markers which are within a valid region
return unless marker.type == 'src' and rc = marker.regionCode
@hits.region[rc] ||= {}
Expand All @@ -99,10 +104,14 @@ class Honeymap
if @hits.marker["total"] > config.markersMaxVisible then @removeOldestMarker()
@mapObj.addMarker(marker.id(), { latLng: marker.gps(), name: marker.name(), style: @config.colors[marker.type] }, [])

@eventCountSummary: (hits) ->
@eventCountSummary: (hits, origin) ->
return unless hits?
total = 0
summary = "<hr/>"
if origin == "dst"
summary += "<b>Destination:</b><br/>"
else if origin == "src"
summary += "<b>Source:</b><br/>"
for type, count of hits
count ||= 0
summary += "<b>#{type}</b>: #{count}<br/>"
Expand Down