Skip to content

Commit

Permalink
adjust bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Oct 11, 2024
1 parent 1f4d0b6 commit 7ec3141
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions static/coffee/v2_locations.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ $(->
fillOpacity: 1
}

PacificCRS = JSON.parse(JSON.stringify(L.CRS.EPSG3857))
PacificCRS.wrapLng = [0, 360]

# our leaflet options
options = {
# no user controlled zooming
Expand All @@ -43,7 +40,6 @@ $(->

# don't allow dragging
dragging: false
crs: PacificCRS
}


Expand Down Expand Up @@ -159,7 +155,11 @@ $(->

states.setStyle(countStyle)
map.addLayer(states)
map.fitBounds(states.getBounds())
bounds = states.getBounds()
map.fitBounds([
[bounds.getNorth(), bounds.getEast() if bounds.getEast() > 0 else bounds.getEast() + 360 ],
[bounds.getNorth(), bounds.getWest() if bounds.getWest() > 0 else bounds.getWest() + 360]
])

info.update()

Expand Down Expand Up @@ -233,9 +233,16 @@ $(->
stateResults = countMap

$("#poll-map-placeholder").addClass('hidden')
map.fitBounds(boundaries.getBounds());
bounds = boundaries.getBounds()
map.fitBounds([
[bounds.getNorth(), bounds.getEast() if bounds.getEast() > 0 else bounds.getEast() + 360 ],
[bounds.getNorth(), bounds.getWest() if bounds.getWest() > 0 else bounds.getWest() + 360]
]);
map.on 'resize', (e) ->
map.fitBounds(boundaries.getBounds())
map.fitBounds([
[bounds.getNorth(), bounds.getEast() if bounds.getEast() > 0 else bounds.getEast() + 360 ],
[bounds.getNorth(), bounds.getWest() if bounds.getWest() > 0 else bounds.getWest() + 360]
])
info.update()

info.addTo(map);
Expand Down Expand Up @@ -263,7 +270,11 @@ $(->
map = L.map(id, options)
boundaries = L.geoJSON(states, {style: emptyStyle})
boundaries.addTo(map);
map.fitBounds(boundaries.getBounds());
bounds = boundaries.getBounds()
map.fitBounds([
[bounds.getNorth(), bounds.getEast() if bounds.getEast() > 0 else bounds.getEast() + 360 ],
[bounds.getNorth(), bounds.getWest() if bounds.getWest() > 0 else bounds.getWest() + 360]
]);
return

map = initMap(id, states, url, districtZoom, wardZoom)
Expand Down

0 comments on commit 7ec3141

Please sign in to comment.