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

Jvector Map error : Uncaught ReferenceError: jvm is not defined #454

Open
abnitchauhan opened this issue Mar 25, 2019 · 1 comment
Open

Comments

@abnitchauhan
Copy link

Hi there I am trying to fetch the data from the mysql database through php . I have got the values in JSON format but not able to show it in the Vector Map.
Here is my Script :
`<script type="text/javascript">
var dataC = '';
dataC = JSON.parse(dataC) ;
var countryData = {};
$.each(dataC, function() {
countryData[this.CountryCode] = this.persons;
});

$(function() {
$('#world-map').vectorMap({
map: 'world_mill_en',
series: {
regions: [{
values: countryData, //load the data
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial'}]
},
//-----------------------------------------------
// changed to onRegionLabelShow from onLabelShow
//-----------------------------------------------
onRegionLabelShow: function(e, el, code) {
//search through dataC to find the selected country by it's code
var country =$.grep(dataC, function(obj, index) {
return obj.CountryCode == code;
})[0]; //snag the first one
//only if selected country was found in dataC
if (country != undefined) {
el.html(el.html() +
"
Code: " +country.CountryCode +
"
Name: " + country.Country +
"
persons: " + country.persons);}}
});
});
</script>`

The Code is Showing the Error :
Uncaught ReferenceError: jvm is not defined
at w.fn.init.a.fn.vectorMap

@fraballi
Copy link

fraballi commented Aug 27, 2020

Need to import four js files:

  • jvectormap/jvectormap.js (binds/registers jvm, but also with jQuery: jvm.$ = jQuery)
  • jvectormap/src/map.js (creates jvm.Map constructor)
  • jvectormap/jquery-jvectormap.js (add .vectorMap as a JQuery plugin $.fn.vectorMap and registers 'addMap' or 'set' callbacks, for a later world map registration/update: e.g 'world_mill'), useful on Ajax requests when map data is loaded after.
  • jvectormap-maps/jquery-jvectormap-world-mill.js

If using bower (bower.json), these were the packages:

    "jvectormap": "2.0.5",
    "jvectormap-maps": "*"

Best, using jquery.jvectormap.min.js file from distribution.
Or, run locally: 'build.sh', from downloaded .zip file.
See: build.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants