简体   繁体   中英

How to access the Data-map object properties

How can i access the Datamap object properties?? I tried to print the map.scope but i got undefined. Can anyone please do let me know how can i access the the map object property??

<!DOCTYPE html>
<html>
<head>
  <title>
  </title>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
  <script src="http://d3js.org/topojson.v1.min.js"></script>
  <script src="http://datamaps.github.io/scripts/datamaps.world.min.js?v=1"></script>
  <div id="container" style="width: 400px; height: 400px;"></div>
<script>
    var map = new Datamap({
        scope: 'world',
        element: document.getElementById("container"),
        projection: 'mercator',
        fills: {
          defaultFill: '#f0af0a',
          lt50: 'rgba(0,244,244,0.9)',
          gt50: 'red'
        },

    data: {
      USA: {fillKey: 'lt50' },
    }
      });
    console.log(map.scope);
</script>
</body>
</html>

replace

console.log(map.scope);

with

console.log(map.options.scope);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM