Skip to content

Commit

Permalink
use options.initialzoom for catalog#show maplet view
Browse files Browse the repository at this point in the history
  • Loading branch information
ebenenglish committed Jul 19, 2016
1 parent 0f3fa0b commit 9023604
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Expand Up @@ -7,7 +7,7 @@
var options = $.extend({
tileurl : 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
mapattribution : 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
initialZoom: 2,
initialzoom: 2,
singlemarkermode: true,
searchcontrol: false,
catalogpath: 'catalog',
Expand Down Expand Up @@ -68,7 +68,6 @@
// Setup Leaflet map
map = L.map(this.id, {
center: [0, 0],
zoom: options.initialZoom
});

L.tileLayer(options.tileurl, {
Expand Down Expand Up @@ -147,12 +146,18 @@

/**
* Sets the view of the map, based off of the map bounds
* options.initialzoom is invoked for catalog#show views (unless it would obscure features)
*/
function setMapBounds() {
map.fitBounds(mapBounds(), {
padding: [10, 10],
maxZoom: options.maxzoom
});
if ($('#document').length) {
if (map.getZoom() > options.initialzoom) {
map.setZoom(options.initialzoom)
}
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion config/jetty.yml
Expand Up @@ -3,5 +3,5 @@ development:
jetty_port: 8983
test:
startup_wait: 60
jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8983 %>
<%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
5 changes: 3 additions & 2 deletions spec/features/show_view_maplet_spec.rb
Expand Up @@ -72,8 +72,9 @@

before :each do
CatalogController.configure_blacklight do |config|
# set maxzoom so we can test whether initial zoom is correct
# set zoom config so we can test whether setMapBounds() is correct
config.view.maps.maxzoom = 8
config.view.maps.show_initial_zoom = 10
end
visit solr_document_path("2009373514")
end
Expand All @@ -83,7 +84,7 @@
end

it "should zoom to the correct map bounds" do
# if initial zoom >= maxzoom, zoom-in control will be disabled
# if setMapBounds() zoom >= maxzoom, zoom-in control will be disabled
expect(page).to have_selector(".leaflet-control-zoom-in.leaflet-disabled")
end

Expand Down

0 comments on commit 9023604

Please sign in to comment.