16124

Get name of selected country from jQuery Vector Maps

Question:

Im trying to use jQuery Vector Maps.

Everything works but i just dont know how i can get name of clicked country. I need this to use that name country in my different jQuery code.

Here is simple documentation: <a href="http://jvectormap.com/documentation/javascript-api-v1/jvm-worldmap/" rel="nofollow">http://jvectormap.com/documentation/javascript-api-v1/jvm-worldmap/</a>

I think that i will have to use: getMapObject

But how i have to use it? Where put this getCode?

Answer1:

I did it with this code

$(function(){ $('#world-map').vectorMap({ backgroundColor: '#000', map: 'world_map', series: { regions: [{ values: countryDamage, scale: ['#FFEECF', '#FF2C2C'], normalizeFunction: 'polynomial' }] }, onRegionClick: function(event, code){ var map = $('#world-map').vectorMap('get', 'mapObject'); alert(map.getRegionName(code)); } }); });

Answer2:

Use This

<script> $('.map_jvector').vectorMap({ map: 'your_name_map', backgroundColor: '#ffffff', onRegionClick:function(event, code){ var name = (code); alert(name); } }); </script>

Recommend

  • Adding Play/Pause to WebGL, in PHP JS only
  • JVectormap zoom in by code
  • Why == is different for Integer and String?
  • Creating interactive SVG maps for a web portal
  • Rails 5 - Google Maps - Javascript error - initMap is not a function - fixing one js issue creates a
  • Javascript: Looping through an array to create listeners, issue with call by reference and value?
  • How to add the custom button on google's(device) native application in android?
  • Uber API - requests endpoint cannot read read json
  • Find VMID for running instance
  • Unable to play media with vlc ocx
  • Embedded Google Maps in Rails not responsive
  • Detecting # in Scheme list
  • pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python
  • Request response issues in biztalk
  • What is the correct way to synchronize a shared, static object in Java?
  • Using $compile in a directive triggers AngularJS infinite digest error
  • KnockoutObservableArray with typed elements in TypeScript
  • Update Google Maps traffic layer without page reloading
  • Image map in Flex
  • Updating both a ConcurrentHashMap and an AtomicInteger safely
  • Entity Framework Code First TPC Inheritance Self-Referencing Child Class
  • Eclipse CDT error: Unable to compile
  • D3 nodes and links from JSON with nested arrays of children
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Updating server-side rendering client-side
  • script to move all files from one location to another location
  • Where to put my custom functions in Wordpress?
  • Hazelcast - OperationTimeoutException
  • RestKit - RKRequestDelegate does not exist
  • Revoking OAuth Access Token Results in 404 Not Found
  • How to set the response of a form post action to a iframe source?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Running Map reduces the dimensions of the matrices
  • Android Heatmap on canvas or ImageView
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?