Embedding ArcOnline in HTML

832
0
03-29-2017 07:15 AM
Labels (1)
VipinSaroha
New Contributor

Hello,

I am trying to embed my maps I made on ArcOnline in the HTML and I manage to make tabs to embed them all on one page. However, I am facing some issues which I am not able to understand what is happening with it.

My issues are below:

  1. Every time I use the tabbing method and embed the map on the map on the first tab is centralized in other tabs there it does not get centralized until I click on the home button. I want it to be centralized every time I click on that tab. If I move the map from other tabs to the first tab, they work fine, so I am assuming everything is fine with the map.
  2. Also, the attribute table does not open when the map is in another tab then the first active tab.

 

I am putting my code below for your reference.

Kindly, let me know is there is a possibility to change this behavior of this map.

I am not able to figure out what is wrong.

 

Best Regards,

Vipin

arconline‌ html‌ arcmap help‌ arcmap‌ arcgis online webapp builder‌

<!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&extent=-17..."></iframe>
</div>

</div>
<script>
function openMap(evt, mapname) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent.style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks.className = tablinks.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 Kudos
0 Replies