简体   繁体   中英

Can't select country paths on tag name in datamaps (d3, javascript)

I'm working on drawing arcs between countries in datamaps. I've added country coordinates to each country path, but i want to retrieve that information now by selecting on tag name (as that is how they are marked)

    <body>
        <div id="map" class="container" style="position: relative; width: 1000px; height:600px;">
    <svg style="overflow: hidden;" height="605" class="datamap" data-width="1005" width="1005"><g class="datamaps-subunits" id="">
    <path y="428.1202655740264" x="434.98315269028086" style="fill: rgb(255, 255, 0); stroke-width: 1; stroke-opacity: 1; stroke: rgb(253, 253, 253);" class="datamaps-subunit FRA" d="M540.4628749226546...377.01608532029195Z
</path></svg>
        </div>   
    </body>

I want to select this specific element and retrieve the x and y values. But document.getElementByTagName("datamaps-subunit FRA").length returns 0 . What do i do wrong here?

应该是getElementsByClassName

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