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

Early voting sidebar markers #75

Open
wants to merge 3 commits 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
3 changes: 2 additions & 1 deletion app/scripts/early_voting_mgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ define(
$el.find('#early-voting-sidebar').html(ejs.render(earlyVotingSidebarTmpl, {
moment: moment,
locations: earlyVotingLocations,
getDirections: getDirections
getDirections: getDirections,
earlyPollingMarkers: mapService.getEarlyPollingMarkers()
}));

listenToSidebarEvents();
Expand Down
26 changes: 21 additions & 5 deletions app/scripts/map_service.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define(['json!vendor/EARLY_VOTING_AddressPoints.geojson'],
function(earlyPollingJSON) {

var hoverIcon = "https://mts.googleapis.com/maps/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png&text=&psize=30&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1"
var defaultIcon = "https://mts.googleapis.com/maps/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=&psize=30&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1"
var hoverIcon = "https://mts.googleapis.com/maps/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png&text=&psize=30&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1"
var defaultIcon = "https://mts.googleapis.com/maps/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=&psize=30&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1"


var DEFAULT_ZOOM_LEVEL = 13;
Expand Down Expand Up @@ -34,6 +34,7 @@ define(['json!vendor/EARLY_VOTING_AddressPoints.geojson'],
}


var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var earlyPollingMarkers = [];


Expand All @@ -52,9 +53,13 @@ define(['json!vendor/EARLY_VOTING_AddressPoints.geojson'],
}

function createEarlyPollingMarkers() {

var labelIndex = 0;
earlyPollingLocations.forEach(function(poll, index) {
var earlyVotingMarker = new google.maps.Marker({
position: poll.getGeometry().get()
position: poll.getGeometry().get(),
label: labels[labelIndex++ % labels.length],
animation: google.maps.Animation.DROP
});
earlyVotingMarker.addListener('click', function() {
fireMarkerEvent('click', earlyVotingMarker);
Expand Down Expand Up @@ -140,10 +145,17 @@ define(['json!vendor/EARLY_VOTING_AddressPoints.geojson'],


changeMarkerColor:function(index, color) {
var defaultState = "background: url("+defaultIcon+") no-repeat;height:40px;";
var hoverState = "background: url("+hoverIcon+") no-repeat;height:40px;";

if (color === "hover") {
earlyPollingMarkers[index].setIcon(hoverIcon);
earlyPollingMarkers[index].setIcon( hoverIcon );
earlyPollingMarkers[index].setLabel("");
document.getElementById('marker_'+index).setAttribute('style', hoverState);
} else if (color === "default") {
earlyPollingMarkers[index].setIcon(defaultIcon);
earlyPollingMarkers[index].setIcon();
earlyPollingMarkers[index].setLabel(labels[index]);
document.getElementById('marker_'+index).setAttribute('style', defaultState);
}
},

Expand All @@ -165,6 +177,10 @@ define(['json!vendor/EARLY_VOTING_AddressPoints.geojson'],
subscribeToMarkerEvents: function(cb) {
markerEventListeners.push(cb);
},

getEarlyPollingMarkers: function() {
return earlyPollingMarkers;
},

displayNewPollingPlace: function(latLng, destination, precinct, successCallback, errorCallback) {

Expand Down
10 changes: 10 additions & 0 deletions app/scripts/templates/early_voting_sidebar.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<% locations.forEach(function(location, i) { %>
<div class="early-voting-location" id="location<%= i %>">
<div
id="marker_<%= i %>"
style="
background: url(https://maps.gstatic.com/mapfiles/api-3/images/spotlight-poi-dotless.png) no-repeat;
height:40px;
"
>
&nbsp;
<%= ""+earlyPollingMarkers[i].label %>
</div>
<div id="heading<%= i %>" role="tab">
<h4>
<a role="button" data-toggle="collapse" data-parent="#early-voting-sidebar" href="#collapse<%= i %>" aria-expanded="false" aria-controls="collapse<%= i %>">
Expand Down