Skip to content

Min and max zoom level options for markers #5

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

Open
wants to merge 2 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
pkg/*
pkg/**/*
*.swp
*.swo
*.scratch.*
.DS_Store
.bundle
.rvmrc
8 changes: 7 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ These are options that can be passed to the `jMapping` function to change specif
* `force_zoom_level`:
* *Default*: *N/A*
* This will force the map to **always** be rendered at this zoom level.
* `marker_max_zoom`:
* *Default*: `null`
* Use this option to set the maximum zoom level for your markers. If you zoom in beyond this level, Markers will not be visible. If a null value is used, the maximum map zoom level will be assumed.
* `marker_min_zoom`:
* *Default*: `9`
* Use this option to set the minimum zoom level for your markers. If you zoom out beyond this level, Markers will not be visible.
* `always_show_markers`:
* *Default*: `false`
* Set this option to `true` if you wish to display markers on all zoom levels. (Normally, the markers may only be visible on certain zoom levels, depending on the normal bounds and zoom level of the marker data.)
* Set this option to `true` to display markers on all zoom levels and override the `marker_min_zoom` and `marker_max_zoom` values.

Object API
-----------
Expand Down
11 changes: 7 additions & 4 deletions jquery.jmapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@
var updateMarkerManager = function(){
if (settings.always_show_markers === true) {
min_zoom = 0;
max_zoom = null;
} else {
zoom_level = map.getZoom();
min_zoom = (zoom_level < 7) ? 0 : (zoom_level - 7);
min_zoom = settings.marker_min_zoom;
max_zoom = settings.marker_max_zoom;
}
markerManager.addMarkers(gmarkersArray(), min_zoom);
markerManager.addMarkers(gmarkersArray(), min_zoom, max_zoom);
markerManager.refresh();
if (settings.force_zoom_level){
map.setZoom(settings.force_zoom_level);
Expand Down Expand Up @@ -266,7 +267,9 @@
info_window_selector: '.info-box',
info_window_max_width: 425,
default_point: {lat: 0.0, lng: 0.0},
metadata_options: {type: 'attr', name: 'data-jmapping'}
metadata_options: {type: 'attr', name: 'data-jmapping'},
marker_max_zoom: null,
marker_min_zoom: 9
},
makeGLatLng: function(place_point){
return new google.maps.LatLng(place_point.lat, place_point.lng);
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Screw.Specifications.mockGMapsUpdate = function(){
// mock out GMap2
var gmap_mock = Smoke.Mock();
gmap_mock.should_receive('fitBounds').exactly('twice');
gmap_mock.should_receive('getZoom').exactly('once').and_return(10);
$.extend(google.maps.Map.prototype, gmap_mock);

// mock out Bounds
Expand Down