jvectormap icon indicating copy to clipboard operation
jvectormap copied to clipboard

Jvector Map error : Uncaught ReferenceError: jvm is not defined

Open abnitchauhan opened this issue 5 years ago • 1 comments

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 : `

$(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);}} }); }); `

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

abnitchauhan avatar Mar 25 '19 11:03 abnitchauhan

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

fraballi avatar Aug 27 '20 13:08 fraballi