### Check Pip Installation Source: https://github.com/10bestdesign/jqvmap/blob/master/create/README.md Verify that Python's package installer, pip, is correctly installed and accessible in your system's PATH. ```bash which pip ``` -------------------------------- ### Initialize Croatia Map with JQVMap Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/croatia.html This snippet shows the basic setup for displaying a Croatia map using JQVMap. It configures map settings, colors, and interactivity. ```javascript jQuery(document).ready(function () { jQuery('#vmap').vectorMap({ map: 'croatia', backgroundColor: '#333333', color: '#ffffff', hoverOpacity: 0.7, selectedColor: '#999999', enableZoom: true, showTooltip: true, scaleColors: ['#C8EEFF', '#006491'], normalizeFunction: 'polynomial' }); }); ``` -------------------------------- ### Install Required Python Packages Source: https://github.com/10bestdesign/jqvmap/blob/master/create/README.md Install the GDAL Python package, Shapely, and Booleano using easy_install and pip. Ensure Python and GDAL binaries are installed first. ```bash sudo easy_install GDAL pip install shapely pip install booleano ``` -------------------------------- ### Install GDAL via Homebrew (macOS) Source: https://github.com/10bestdesign/jqvmap/blob/master/create/README.md Install the GDAL library using the Homebrew package manager on macOS. Note that this method may sometimes lead to issues. ```bash brew update brew install gdal ``` -------------------------------- ### Handle Map Drag Event Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md This example shows how to bind a custom callback function to the 'drag' event, which is triggered whenever the map is being dragged. ```javascript jQuery('#vmap').on('drag', function(event) { console.log('The map is being dragged'); //Do something }); ``` -------------------------------- ### Get All Pins Data Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md Retrieves a JSON string containing the stringified HTML content of all pins currently on the map. ```javascript var pins = jQuery('#vmap').vectorMap('getPins'); ``` -------------------------------- ### Get Pin HTML Content by Country Code Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md Retrieves the stringified HTML content of a pin associated with a specific country code. ```javascript var pinContent = jQuery('#vmap').vectorMap('getPin', 'pk'); ``` -------------------------------- ### Get Pin HTML ID by Country Code Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md Retrieves the HTML 'id' attribute of a pin associated with a specific country code. ```javascript var pinId = jQuery('#vmap').vectorMap('getPinId', 'pk'); ``` -------------------------------- ### Run Sample Map Creation Commands Source: https://github.com/10bestdesign/jqvmap/blob/master/create/README.md Execute the jqvmap.py script with pre-defined configuration files for different maps. ```bash cd /path/to/jqvmap/create python jqvmap.py config/continent.json ``` ```bash python jqvmap.py config/new-york.json ``` ```bash python jqvmap.py config/syria.json ``` -------------------------------- ### Sample Map Configuration JSON Source: https://github.com/10bestdesign/jqvmap/blob/master/create/README.md A sample JSON file for configuring map creation. Pay attention to 'code_field' and 'name_field' which correspond to columns in your data. ```json [ { "name": "read_data", "file_name": "./source/some-folder/some-file.shp" }, { "name": "write_data", "format": "jqvmap", "file_name": "./output/jquery.vmap.my-map.js", "params": { "code_field": "iso_column", "name_field": "name_column", "name": "my-map" } } ] ``` -------------------------------- ### Load World Map with Default Settings Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md This snippet shows how to initialize the JQVMap plugin to display a world map with default configurations. It includes basic event handling for region hovers. ```javascript jQuery('#vmap').vectorMap({ map: 'world_en', backgroundColor: '#333', color: '#ffffff', hoverOpacity: 0.7, selectedColor: '#666666', enableZoom: true, showTooltip: true, onRegionClick: function(event, code) { //example common data format var country data = { "us" : { "name" : "United States", "value" : "100" }, "ru" : { "name" : "Russia", "value" : "100" }, "cn" : { "name" : "China", "value" : "100" } }; if (country data[code]) { label.html(country data[code].name + " (" + country data[code].value + ")"); } else { label.html('Country code is: ' + code); } }, onRegionOver: function(event, code) { if (code == 'ca') { event.preventDefault(); } }, }); ``` -------------------------------- ### Initialize Russia Map with JQVMap Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/russia.html Use this snippet to display an interactive map of Russia. Configure colors, zoom, and tooltips as needed. ```javascript jQuery(document).ready(function () { jQuery('#vmap').vectorMap({ map: 'russia_en', backgroundColor: '#333333', color: '#ffffff', hoverOpacity: 0.7, selectedColor: '#999999', enableZoom: true, showTooltip: true, scaleColors: ['#C8EEFF', '#006491'], normalizeFunction: 'polynomial' }); }); ``` -------------------------------- ### Initialize Iran Map with JQVMap Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/iran.html Initializes the JQVMap plugin with the 'iran_ir' map and customizes its appearance and behavior. Includes a click handler for regions. ```javascript jQuery(document).ready(function () { jQuery('#vmap').vectorMap({ map: 'iran_ir', backgroundColor: '#fff', borderColor: '#818181', borderOpacity: 0.25, borderWidth: 2, color: '#eee', enableZoom: false, hoverColor: '#DA251D', hoverOpacity: null, normalizeFunction: 'linear', selectedColor: '#fff', showTooltip: true, onRegionClick: function (element, code, region) { var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase(); alert(message); } }); }); ``` -------------------------------- ### Load World Map with Default Settings Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md This HTML snippet demonstrates how to load the JQVMap world map with default configurations. It includes necessary CSS and JavaScript includes, along with the jQuery ready function to initialize the map. ```html
*/, ... },
pinMode: 'content'
});
```
--------------------------------
### Initialize Indonesia Map with JQVMap
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/indonesia.html
This snippet initializes the JQVMap plugin with the 'indonesia_id' map. It enables zooming and tooltips, and sets up a click handler for map regions. Use this for interactive map displays.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'indonesia_id',
enableZoom: true,
showTooltip: true,
selectedColor: null,
onRegionClick: function(event, code, region) {
event.preventDefault();
}
});
});
```
--------------------------------
### Initialize Greece Map with Click Handler
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/greece.html
Initializes the JQVMap with the 'greece' map and defines a callback function for region clicks. Use this to add interactivity to your map.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'greece',
onRegionClick: function (element, code, region) {
var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
alert(message);
}
});
});
```
--------------------------------
### Initialize Europe Map with JQVMap
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/multi.html
Use this snippet to display an interactive Europe map. It enables zooming, tooltips, and allows multiple regions to be selected, pre-selecting France.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'europe_en',
enableZoom: true,
showTooltip: true,
multiSelectRegion: true,
selectedRegions: ['FR']
});
});
```
--------------------------------
### Initialize JQVMap with Iraq Map
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/iraq.html
This snippet initializes the JQVMap plugin to display an interactive map of Iraq. It includes basic styling and an event handler for region clicks.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'iraq',
backgroundColor: '#fff',
borderColor: '#818181',
borderOpacity: 0.25,
borderWidth: 1,
color: '#eee',
enableZoom: false,
hoverColor: '#DA251D',
hoverOpacity: null,
normalizeFunction: 'linear',
selectedColor: '#fff',
showTooltip: true,
onRegionClick: function (element, code, region) {
var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
alert(message);
}
});
});
```
--------------------------------
### Initialize Map with Multiple Callbacks
Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md
Initializes the JQVMap with several common callback functions defined directly in the options object. These callbacks are triggered by various map events.
```js
jQuery('#vmap').vectorMap(
{
onLoad: function(event, map)
{
},
onLabelShow: function(event, label, code)
{
},
onRegionOver: function(event, code, region)
{
},
onRegionOut: function(event, code, region)
{
},
onRegionClick: function(event, code, region)
{
},
onResize: function(event, width, height)
{
}
});
```
--------------------------------
### Initialize Brazil Map with Click Handler
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/brazil.html
Initializes the JQVMap with the Brazil map and defines a callback function for region clicks. The callback displays an alert with the region name and its code.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'brazil_br',
onRegionClick: function (element, code, region) {
var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
alert(message);
}
});
});
```
--------------------------------
### Visualize GDP Data on World Map
Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md
This snippet demonstrates how to visualize geographical data, specifically GDP in 2010, by dynamically coloring map regions based on their values. It requires a 'gdp-data.js' file containing country codes and GDP values.
```javascript
var gdpData = {"af":16.63,"al":11.58,"dz":158.97,...};
```
```javascript
var max = 0,
min = Number.MAX_VALUE,
cc,
startColor = [200, 238, 255],
endColor = [0, 100, 145],
colors = {},
hex;
//find maximum and minimum values
for (cc in gdpData)
{
if (parseFloat(gdpData[cc]) > max)
{
max = parseFloat(gdpData[cc]);
}
if (parseFloat(gdpData[cc]) < min)
{
min = parseFloat(gdpData[cc]);
}
}
//set colors according to values of GDP
for (cc in gdpData)
{
if (gdpData[cc] > 0)
{
colors[cc] = '#';
for (var i = 0; i<3; i++)
{
hex = Math.round(startColor[i]
+ (endColor[i]
- startColor[i])
* (gdpData[cc] / (max - min))).toString(16);
if (hex.length == 1)
{
hex = '0'+hex;
}
colors[cc] += (hex.length == 1 ? '0' : '') + hex;
}
}
}
//initialize JQVMap
jQuery('#vmap').vectorMap(
{
colors: colors,
hoverOpacity: 0.7,
hoverColor: false
});
```
--------------------------------
### Initialize JQVMap with Pins
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/pins.html
Initializes the JQVMap world map with predefined pins for Russia (ru) and Pakistan (pk). Pins are defined as HTML anchor tags with associated href attributes.
```javascript
var pins = { 'ru': "\u003ca target=\"_blank\" href=\"http://www.google.com.ru\"\u003epin_ru\u003c/a\u003e", 'pk': "\u003ca target=\"_blank\" href=\"http://www.google.com.pk\"\u003epin_pk\u003c/a\u003e" };
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'world_en',
backgroundColor: '#333333',
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#666666',
enableZoom: true,
showTooltip: true,
scaleColors: ['#C8EEFF', '#006491'],
normalizeFunction: 'polynomial',
pins: {
"ru": "\u003ca href=\"http://google.com\"\u003epin_ru\u003c/a\u003e",
"pk": "\u003ca href=\"http://google.com\"\u003epin_pk\u003c/a\u003e"
}
});
});
```
--------------------------------
### JQVMap Tabbed Interface and Initialization
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/continents.html
This snippet handles the click events for tabbed navigation to switch between different JQVMap continents and initializes the first map with a selected state. It also includes basic CSS for the tabs and map containers.
```javascript
jQuery(document).ready(function () {
$('h2').each(function () {
$(this).click(function () {
$('.tab-selected').removeClass('tab-selected');
$(this).addClass('tab-selected');
$('.map').css('z-index', '0');
$('#vmap-' + this.id).parent().css('z-index', '1');
});
});
$('h2:first').addClass('tab-selected');
$('.map:first').css('z-index', '1');
});
```
```css
* {
margin: 0;
padding: 0;
}
h2 {
background: none repeat scroll 0 0 #cccccc;
border: 1px solid #aaaaaa;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
float: left;
padding: 5px;
font-size: 20px;
font-weight: normal;
cursor: pointer;
}
h2.tab-selected {
background: #888888;
border: 1px solid #000000;
}
.map {
position: absolute;
z-index: 0;
left: 0;
top: 35px;
}
```
--------------------------------
### Basic JQVMap Europe Map Initialization
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/mobile.html
Initializes a JQVMap with the Europe map. Ensure the JQVMap library and the Europe map file are included.
```html
html, body { padding: 0; margin: 0; width: 100%; height: 100%; }
#vmap { width: 100%; height: 100%; background-color: red;
-webkit-tap-highlight-color: rgba(0,0,0,0); }
.jqvmap-zoomin { width: 30px; height: 30px; line-height: 30px; }
.jqvmap-zoomout { width: 30px; height: 30px; top: 55px; line-height: 30px; }
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'europe_en',
enableZoom: true,
showTooltip: true
});
});
```
--------------------------------
### Initialize Europe Map with JQVMap
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/europe.html
This snippet shows how to initialize the JQVMap plugin to display a Europe map. It disables zooming and tooltips for a static display.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'europe_en',
enableZoom: false,
showTooltip: false
});
});
```
--------------------------------
### Initialize USA Districts Map
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/usa_districts.html
Initializes a JQVMap with the USA districts map. Configure options like border color, zoom, tooltips, and click events.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'usa_districts_en',
borderColor: '#000',
enableZoom: true,
showTooltip: true,
selectedColor: null,
hoverColor: '#639',
onRegionClick: function (event, code, region) {
event.preventDefault();
}
});
});
```
--------------------------------
### Initialize JQVMap with Europe Map
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/responsive.html
This snippet initializes the JQVMap with the 'usa_en' map, enabling zoom and tooltips. It also includes a basic resize event handler.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'usa_en',
enableZoom: true,
showTooltip: true,
onResize: function (element, width, height) {
console.log('Map Size: ' + width + 'x' + height);
}
});
});
```
--------------------------------
### Initialize USA Counties Map
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/usa_counties.html
Initializes the JQVMap with the 'usa_counties_en' map. Configure zoom, tooltips, hover color, and a click handler for regions.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'usa_counties_en',
enableZoom: true,
showTooltip: true,
hoverColor: '#C9DFAF',
onRegionClick: function(event, code, region) {
event.preventDefault();
}
});
});
```
--------------------------------
### Create a Major Release
Source: https://github.com/10bestdesign/jqvmap/blob/master/CONTRIBUTING.md
Increases the major version number, builds and packages distribution files, and performs a git commit. Use this for significant, backward-incompatible changes.
```bash
grunt release-major
```
--------------------------------
### Display Ukraine Map with JQVMap
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/ukraine.html
Initializes the JQVMap plugin to display an interactive map of Ukraine. Configure colors, zoom, and tooltips for a customized user experience.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'ukraine_ua',
backgroundColor: '#fff',
borderColor: '#fff',
color: '#279fe0',
hoverColor: '#005bbb',
selectedColor: '#ffd500',
enableZoom: true,
showTooltip: true,
});
});
```
--------------------------------
### JQVMap Label Styling and Responsiveness
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/labels.html
Customizes the appearance and behavior of map labels using CSS. Includes rules for general label styling, hiding specific labels, repositioning labels, and adjusting font size based on screen width.
```css
html, body { padding: 0; margin: 0; width: 100%; height: 100%; }
#vmap { width: 100%; height: 100%; background-color: red; -webkit-tap-highlight-color: rgba(0,0,0,0); }
/* Setup basic CSS for Label */
.jqvmap-pin { font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
cursor: default;
pointer-events: none;
}
/* Hide Whichever Labels you want */
#jqvmap1_ri_pin, #jqvmap1_dc_pin, #jqvmap1_de_pin, #jqvmap1_md_pin { display: none; }
/* Reposition Labels that are not quite right ( labels are centered in shape, and sometimes need tweaking ) */
#jqvmap1_ak_pin { margin-top: -2%; }
#jqvmap1_ca_pin { margin-left: -2%; }
#jqvmap1_ct_pin { margin-top: -0.25%; margin-left: -0.25%; }
#jqvmap1_fl_pin { margin-left: 5%; }
#jqvmap1_id_pin { margin-top: 3%; margin-left: -1%; }
#jqvmap1_ky_pin { margin-left: 2%; }
#jqvmap1_la_pin { margin-left: -2%; }
#jqvmap1_mi_pin { margin-top: 4%; margin-left: 3%; }
#jqvmap1_ma_pin { margin-top: -0.25%; }
#jqvmap1_mn_pin { margin-top: 2%; margin-left: -2%; }
#jqvmap1_nh_pin { margin-top: 1%; margin-left: -0.25%; }
#jqvmap1_nj_pin { margin-top: 1%; }
#jqvmap1_ok_pin { margin-left: 2%; }
#jqvmap1_va_pin { margin-left: 2%; }
#jqvmap1_wv_pin { margin-left: -1%; margin-top: 1%; }
/* Add responsibe support to resize labels for difference screen sizes */
@media only screen and (min-width: 320px) {
.jqvmap-pin { font-size: 6px; }
}
@media only screen and (min-width: 480px) {
.jqvmap-pin { font-size: 8px; }
}
@media only screen and (min-width: 640px) {
.jqvmap-pin { font-size: 10px; }
}
@media only screen and (min-width: 800px) {
.jqvmap-pin { font-size: 12px; }
}
@media only screen and (min-width: 1024px) {
.jqvmap-pin { font-size: 14px; }
}
```
--------------------------------
### Initialize World Map with ID Pins
Source: https://github.com/10bestdesign/jqvmap/blob/master/README.md
Loads the world map and places pins using element IDs. The 'pins' option takes an object where keys are country codes and values are the 'id' attributes of HTML elements to be used as pins.
```html
```
--------------------------------
### Display Argentina Map with Click Events
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/argentina.html
Initializes a JQVMap for Argentina and defines a callback function for region clicks. Use this to add interactivity to your map.
```javascript
jQuery(document).ready(function () {
jQuery('#vmap').vectorMap({
map: 'argentina_en',
onRegionClick: function (element, code, region) {
var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
alert(message);
}
});
});
```
--------------------------------
### Create a Minor Release
Source: https://github.com/10bestdesign/jqvmap/blob/master/CONTRIBUTING.md
Increases the minor version number, builds and packages distribution files, and performs a git commit. Use this for backward-compatible new features.
```bash
grunt release-minor
```
--------------------------------
### Create a Release Patch
Source: https://github.com/10bestdesign/jqvmap/blob/master/CONTRIBUTING.md
Increases the patch version number, builds and packages distribution files, and performs a git commit. Use this for backward-compatible bug fixes.
```bash
grunt release-patch
```
--------------------------------
### Initialize JQVMap for Africa
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/continents.html
Initializes the JQVMap for the Africa continent. This includes setting the map type, background color, default color, hover opacity, selected color, zoom and tooltip settings, data values, scale colors, and normalization function.
```javascript
jQuery('#vmap-africa').vectorMap({
map: 'africa\_en',
backgroundColor: '#333333',
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#666666',
enableZoom: true,
showTooltip: true,
values: sample_data,
scaleColors: ['#C8EEFF', '#006491'],
normalizeFunction: 'polynomial'
});
```
--------------------------------
### USA Map with Custom Pins
Source: https://github.com/10bestdesign/jqvmap/blob/master/examples/pins_custom.html
Initializes a USA map using JQVMap, specifying custom HTML content for pins and handling region click events. Ensure the JQVMap library and necessary map files are included.
```javascript
function escapeXml(string) {
return string.replace(/[<>]/g, function (c) {
switch (c) {
case '<': return '\u003c';
case '>': return '\u003e';
}
});
}
jQuery(document).ready(function () {
var pins = {
mo: escapeXml('