HTML中的嵌入式ArcOnline地图未显示在集中显示中

时间:2017-03-29 14:04:08

标签: javascript html arcgis esri

我正在尝试将我在ArcOnline上制作的地图嵌入到HTML中,并设法制作标签以将它们全部嵌入到一个页面上。但是,我面临一些问题,我无法理解它发生了什么。 我的问题如下: 每次我使用tabbing方法并在第一个选项卡上的地图上嵌入地图都集中在其他选项卡中,直到我点击主页按钮才会集中。我希望每次单击该选项卡时都将其集中。如果我将地图从其他标签移动到第一个标签,它们工作正常,所以我假设地图上的一切都很好。 此外,当地图位于另一个选项卡中,然后是第一个活动选项卡时,属性表不会打开。

我的完整html代码最后供参考。 请允许我知道是否有可能改变此地图的这种行为。 我无法弄清楚出了什么问题。

<!DOCTYPE html> <html> <head> <style> body {font-family: "Arial", sans-serif;}

/* Style the tab */ div.tab {
    overflow: hidden;
    border: 1px solid #ccc;
    background-color: #f1f1f1; }

/* Style the buttons inside the tab */ div.tab button {
    background-color: inherit;
    float: left;
    border: black;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: 0.3s;
    font-size: 17px; }

/* Change background color of buttons on hover */ div.tab button:hover {
    background-color: #fff; }

/* Create an active/current tablink class */ div.tab button.active {
    background-color: lightblue; }

/* Style the tab content */ .tabcontent {
    display: none;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-top: green; } </style> </head> <body>

<div class="tab">   <button class="tablinks" onclick="openMap(event, 'Mapwithlayers')" id="defaultOpen">Mapwithlayers</button>   <button class="tablinks" onclick="openMap(event, 'Mapwithfilters')">Mapwithfilters</button>   <button class="tablinks" onclick="openMap(event, 'GreyMapLayer')">GreyMapLayer</button>   <div id="Mapwithlayers" class="tabcontent">   <span onclick="this.parentElement.style.display='none'" class="topright"></span>

    <iframe width="100%" height="840px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://arcg.is/2nLnY5A">
    </iframe> </div>

<div id="Mapwithfilters" class="tabcontent">   <span onclick="this.parentElement.style.display='none'" class="topright"></span>

      <iframe width="100%" height="840px" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://arcg.is/2nLnY5A"></iframe>
      </div>
     <div id="GreyMapLayer" class="tabcontent">   <span onclick="this.parentElement.style.display='none'" class="topright"></span>

      <iframe width="100%" height="840px" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://un13.maps.arcgis.com/apps/Embed/index.html?webmap=1f25e4d600ad49539404f8c00c771a5a&amp;extent=-177.7678,-52.1584,172.6076,78.4721&amp;home=true&amp;zoom=true&amp;scale=true&amp;legend=true&amp;disable_scroll=true&amp;theme=light"></iframe> </div>

</div> <script> function openMap(evt, mapname) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace("active", "");
    }
    document.getElementById(mapname).style.display = "block";
    evt.currentTarget.className += "active"; }

// Get the element with id="defaultOpen" and click on it document.getElementById("defaultOpen").click(); </script>
      </body> </html>

0 个答案:

没有答案