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

Fix #269 by adding setSelectedRegions function #271

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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jqvmap",
"version": "1.5.0",
"version": "1.5.2",
"homepage": "http://jqvmap.com",
"authors": [
"JQVMap"
Expand Down
33 changes: 18 additions & 15 deletions dist/jquery.vmap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*!
* JQVMap: jQuery Vector Map Library
* @author JQVMap <[email protected]>
* @version 1.5.1
* @version 1.5.2
* @link http://jqvmap.com
* @license https://github.com/manifestinteractive/jqvmap/blob/master/LICENSE
* @builddate 2016/06/02
* @builddate 2016/11/29
*/

var VectorCanvas = function (width, height, params) {
Expand Down Expand Up @@ -248,13 +248,7 @@ var JQVMap = function (params) {
}

if (params.selectedRegions) {
if (params.selectedRegions instanceof Array) {
for(var k in params.selectedRegions) {
this.select(params.selectedRegions[k].toLowerCase());
}
} else {
this.select(params.selectedRegions.toLowerCase());
}
this.setSelectedRegions(params.selectedRegions);
}

this.bindZoomButtons();
Expand Down Expand Up @@ -853,17 +847,13 @@ JQVMap.prototype.positionPins = function(){
var scale = map.scale;
var rootCoords = map.canvas.rootGroup.getBoundingClientRect();
var mapCoords = map.container[0].getBoundingClientRect();
var coords = {
left: rootCoords.left - mapCoords.left,
top: rootCoords.top - mapCoords.top
};

var middleX = (bbox.x * scale) + ((bbox.width * scale) / 2);
var middleY = (bbox.y * scale) + ((bbox.height * scale) / 2);

pinObj.css({
left: coords.left + middleX - (pinObj.width() / 2),
top: coords.top + middleY - (pinObj.height() / 2)
left: (rootCoords.left - mapCoords.left) + middleX - (pinObj.width() / 2),
top: (rootCoords.top - mapCoords.top) + middleY - (pinObj.height() / 2)
});
});
};
Expand Down Expand Up @@ -971,6 +961,19 @@ JQVMap.prototype.setScaleColors = function (colors) {
}
};

JQVMap.prototype.setSelectedRegions = function (regions) {
for (var key in this.selectedRegions) {
this.deselect(this.selectedRegions[key], undefined);
}
if (regions instanceof Array) {
for(var k in regions) {
this.select(regions[k].toLowerCase());
}
} else {
this.select(regions.toLowerCase());
}
};

JQVMap.prototype.setValues = function (values) {
var max = 0,
min = Number.MAX_VALUE,
Expand Down
6 changes: 3 additions & 3 deletions dist/jquery.vmap.min.js

Large diffs are not rendered by default.

Empty file modified grunt/bump.js
100755 → 100644
Empty file.
26 changes: 13 additions & 13 deletions grunt/changelog.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
release: {
options: {
insertType: "prepend",
template: "## Release v<%= package.version %>:\n\n{{> features}}{{> fixes}}\n\n",
partials: {
features: "#### Features:\n\n{{#if features}}{{#each features}}{{> feature}}{{/each}}{{else}}{{> empty}}{{/if}}\n",
fixes: "#### Bugfixes:\n\n{{#if fixes}}{{#each fixes}}{{> fix}}{{/each}}{{else}}{{> empty}}{{/if}}",
empty: " - (none)\n"
},
dest: "CHANGELOG.md"
}
}
module.exports = {
release: {
options: {
insertType: "prepend",
template: "## Release v<%= package.version %>:\n\n{{> features}}{{> fixes}}\n\n",
partials: {
features: "#### Features:\n\n{{#if features}}{{#each features}}{{> feature}}{{/each}}{{else}}{{> empty}}{{/if}}\n",
fixes: "#### Bugfixes:\n\n{{#if fixes}}{{#each fixes}}{{> fix}}{{/each}}{{else}}{{> empty}}{{/if}}",
empty: " - (none)\n"
},
dest: "CHANGELOG.md"
}
}
};
Empty file modified grunt/clean.js
100755 → 100644
Empty file.
Empty file modified grunt/concat.js
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion grunt/index.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var requireDirectory = require("require-directory");
var requireDirectory = require("require-directory");
module.exports = requireDirectory(module);
Empty file modified grunt/qunit.js
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion grunt/shell.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
lint: {
command: "node_modules/.bin/eslint src --quiet && echo '\033[0;32m\n✓ All Good\033[0m ٩(ˊᗜˋ*)و'",
command: "eslint src --quiet && echo '\033[0;32m\n✓ All Good\033[0m ٩(ˊᗜˋ*)و'",
stdout: false
}
};
Empty file modified grunt/uglify.js
100755 → 100644
Empty file.
Empty file modified gruntfile.js
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jqvmap",
"version": "1.5.1",
"version": "1.5.2",
"homepage": "http://jqvmap.com",
"author": {
"name": "JQVMap",
Expand Down
8 changes: 1 addition & 7 deletions src/JQVMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,7 @@ var JQVMap = function (params) {
}

if (params.selectedRegions) {
if (params.selectedRegions instanceof Array) {
for(var k in params.selectedRegions) {
this.select(params.selectedRegions[k].toLowerCase());
}
} else {
this.select(params.selectedRegions.toLowerCase());
}
this.setSelectedRegions(params.selectedRegions);
}

this.bindZoomButtons();
Expand Down
12 changes: 12 additions & 0 deletions src/JQVMap/setSelectedRegions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
JQVMap.prototype.setSelectedRegions = function (regions) {
for (var key in this.selectedRegions) {
this.deselect(this.selectedRegions[key], undefined);
}
if (regions instanceof Array) {
for(var k in regions) {
this.select(regions[k].toLowerCase());
}
} else {
this.select(regions.toLowerCase());
}
};