<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Map Disappearing on HTML page when Sizing is changed from pixels (px) to percentages (%) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-disappearing-on-html-page-when-sizing-is/m-p/1203619#M78313</link>
    <description>&lt;P&gt;I am trying to allow this map to be resized via screen size (Mobile, Tablet, Chrome (Half Screen, Full Screen, etc.) so I know I can't set a specific pixel amount. However, when I do set a percentage the map disappears on my html page. I would like the map to have a height of 450px and a width of 600px at a maximum and then scale based on a screen size smaller then what can accommodate that.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Marketing Map&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.23/esri/css/main.css" target="_blank"&gt;https://js.arcgis.com/4.23/esri/css/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;/P&gt;&lt;P&gt;html, body {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 450px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;width: 600px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 450px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;width: 650px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;}&lt;BR /&gt;.esri-legend {&lt;BR /&gt;border-radius: 10px;&lt;BR /&gt;background-color: rgba(85, 85, 85, 0.9);&lt;BR /&gt;color: #ddd;&lt;BR /&gt;font-size: 8px;&lt;BR /&gt;max-width: 170px;&lt;BR /&gt;}&lt;BR /&gt;.esri-legend__layer-caption{&lt;BR /&gt;visibility: hidden;&lt;BR /&gt;height: 0px;&lt;BR /&gt;margin-top: -5px;&lt;BR /&gt;}&lt;BR /&gt;.esri-legend__layer-body{&lt;BR /&gt;margin: 0px;&lt;BR /&gt;}&lt;BR /&gt;.esri-widget__heading {&lt;BR /&gt;color: #ddd;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://js.arcgis.com/4.23/" target="_blank"&gt;https://js.arcgis.com/4.23/&lt;/A&gt;"&amp;gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;require([&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/Basemap",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/core/watchUtils",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/layers/MapImageLayer",&lt;BR /&gt;"esri/layers/support/LabelClass",&lt;BR /&gt;"esri/widgets/Search",&lt;BR /&gt;"esri/widgets/Home",&lt;BR /&gt;"esri/widgets/DistanceMeasurement2D",&lt;BR /&gt;"esri/widgets/BasemapGallery",&lt;BR /&gt;"esri/widgets/LayerList",&lt;BR /&gt;"esri/widgets/Expand",&lt;BR /&gt;"esri/widgets/Legend",&lt;BR /&gt;"dojo/query",&lt;BR /&gt;"dojo/dom",&lt;BR /&gt;"dojo/on",&lt;BR /&gt;"dojo/domReady!"&lt;BR /&gt;], function(Map,Basemap,MapView,watchUtils,FeatureLayer,MapImageLayer,LabelClass,Search,Home,DistanceMeasurement2D,BasemapGallery,LayerList,Expand,Legend,query,dom,on, mobile, parser, has, dTheme, registry){&lt;/P&gt;&lt;P&gt;var map = new Map({&lt;BR /&gt;basemap: "gray-vector"&lt;BR /&gt;})&lt;BR /&gt;var view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [-77.11731019866023, 38.82010562165418],&lt;BR /&gt;zoom:11,&lt;BR /&gt;constraints: {&lt;BR /&gt;maxZoom: 11,&lt;BR /&gt;minZoom: 18&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const NbhRender = {&lt;BR /&gt;type: "unique-value",&lt;BR /&gt;field: "Constructi",&lt;BR /&gt;defaulSymbol: {type: "simple-fill"},&lt;BR /&gt;uniqueValueInfos: [{&lt;BR /&gt;value: "Future Construction",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "purple",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}, {&lt;BR /&gt;value: "In Construction",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "red",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}, {&lt;BR /&gt;value: "Live",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "#00aaee",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var nbhLyr = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services8.arcgis.com/AH8GuAfnCoO6STfX/arcgis/rest/services/Alexandria_Boundaries/FeatureServer/0/query?outFields=*&amp;amp;where=1%3D1" target="_blank"&gt;https://services8.arcgis.com/AH8GuAfnCoO6STfX/arcgis/rest/services/Alexandria_Boundaries/FeatureServer/0/query?outFields=*&amp;amp;where=1%3D1&lt;/A&gt;",&lt;BR /&gt;title: "Workzones",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;renderer: NbhRender,&lt;BR /&gt;visible: true,&lt;BR /&gt;opacity: 0.3,&lt;BR /&gt;visibleAtMapScale: true,&lt;BR /&gt;minScale: 2000000,&lt;BR /&gt;maxScale: 0&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const nbhLabelClass = new LabelClass({&lt;BR /&gt;labelExpressionInfo: { expression: "$feature.Name" },&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "text", // autocasts as new TextSymbol()&lt;BR /&gt;color: "black",&lt;BR /&gt;font: {&lt;BR /&gt;weight: "bold",&lt;BR /&gt;size: 10&lt;BR /&gt;},&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;nbhLyr.labelingInfo = [ nbhLabelClass ];&lt;/P&gt;&lt;P&gt;map.add(nbhLyr)&lt;/P&gt;&lt;P&gt;//add legend&lt;BR /&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;visible: true,&lt;BR /&gt;font: {&lt;BR /&gt;size: 1&lt;BR /&gt;},&lt;BR /&gt;layerInfos: [{&lt;BR /&gt;layer: nbhLyr,&lt;BR /&gt;title: "Construction Status"&lt;BR /&gt;}]&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(legend,"bottom-left");&lt;BR /&gt;});&lt;BR /&gt;(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){&lt;BR /&gt;(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),&lt;BR /&gt;m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)&lt;BR /&gt;})(window,document,'script','&lt;A href="https://www.google-analytics.com/analytics.js','ga" target="_blank"&gt;https://www.google-analytics.com/analytics.js','ga&lt;/A&gt;');&lt;/P&gt;&lt;P&gt;ga('create', 'UA-98819163-1', 'auto');&lt;BR /&gt;ga('send', 'pageview');&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;BR /&gt;I have tried to add a div in the body that would hold the px amount and have the % amount in the viewDiv and multiple other approaches but nothing has worked so far.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 06:56:30 GMT</pubDate>
    <dc:creator>RealzahAbbas</dc:creator>
    <dc:date>2022-08-17T06:56:30Z</dc:date>
    <item>
      <title>Map Disappearing on HTML page when Sizing is changed from pixels (px) to percentages (%)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-disappearing-on-html-page-when-sizing-is/m-p/1203619#M78313</link>
      <description>&lt;P&gt;I am trying to allow this map to be resized via screen size (Mobile, Tablet, Chrome (Half Screen, Full Screen, etc.) so I know I can't set a specific pixel amount. However, when I do set a percentage the map disappears on my html page. I would like the map to have a height of 450px and a width of 600px at a maximum and then scale based on a screen size smaller then what can accommodate that.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Marketing Map&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.23/esri/css/main.css" target="_blank"&gt;https://js.arcgis.com/4.23/esri/css/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;/P&gt;&lt;P&gt;html, body {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 450px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;width: 600px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 450px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;width: 650px; #I assume these need to be changed to 100% but the map disappears when I do this&lt;BR /&gt;}&lt;BR /&gt;.esri-legend {&lt;BR /&gt;border-radius: 10px;&lt;BR /&gt;background-color: rgba(85, 85, 85, 0.9);&lt;BR /&gt;color: #ddd;&lt;BR /&gt;font-size: 8px;&lt;BR /&gt;max-width: 170px;&lt;BR /&gt;}&lt;BR /&gt;.esri-legend__layer-caption{&lt;BR /&gt;visibility: hidden;&lt;BR /&gt;height: 0px;&lt;BR /&gt;margin-top: -5px;&lt;BR /&gt;}&lt;BR /&gt;.esri-legend__layer-body{&lt;BR /&gt;margin: 0px;&lt;BR /&gt;}&lt;BR /&gt;.esri-widget__heading {&lt;BR /&gt;color: #ddd;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://js.arcgis.com/4.23/" target="_blank"&gt;https://js.arcgis.com/4.23/&lt;/A&gt;"&amp;gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;require([&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/Basemap",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/core/watchUtils",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/layers/MapImageLayer",&lt;BR /&gt;"esri/layers/support/LabelClass",&lt;BR /&gt;"esri/widgets/Search",&lt;BR /&gt;"esri/widgets/Home",&lt;BR /&gt;"esri/widgets/DistanceMeasurement2D",&lt;BR /&gt;"esri/widgets/BasemapGallery",&lt;BR /&gt;"esri/widgets/LayerList",&lt;BR /&gt;"esri/widgets/Expand",&lt;BR /&gt;"esri/widgets/Legend",&lt;BR /&gt;"dojo/query",&lt;BR /&gt;"dojo/dom",&lt;BR /&gt;"dojo/on",&lt;BR /&gt;"dojo/domReady!"&lt;BR /&gt;], function(Map,Basemap,MapView,watchUtils,FeatureLayer,MapImageLayer,LabelClass,Search,Home,DistanceMeasurement2D,BasemapGallery,LayerList,Expand,Legend,query,dom,on, mobile, parser, has, dTheme, registry){&lt;/P&gt;&lt;P&gt;var map = new Map({&lt;BR /&gt;basemap: "gray-vector"&lt;BR /&gt;})&lt;BR /&gt;var view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [-77.11731019866023, 38.82010562165418],&lt;BR /&gt;zoom:11,&lt;BR /&gt;constraints: {&lt;BR /&gt;maxZoom: 11,&lt;BR /&gt;minZoom: 18&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const NbhRender = {&lt;BR /&gt;type: "unique-value",&lt;BR /&gt;field: "Constructi",&lt;BR /&gt;defaulSymbol: {type: "simple-fill"},&lt;BR /&gt;uniqueValueInfos: [{&lt;BR /&gt;value: "Future Construction",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "purple",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}, {&lt;BR /&gt;value: "In Construction",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "red",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}, {&lt;BR /&gt;value: "Live",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "#00aaee",&lt;BR /&gt;outline: {&lt;BR /&gt;width: 2,&lt;BR /&gt;color: "white"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var nbhLyr = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services8.arcgis.com/AH8GuAfnCoO6STfX/arcgis/rest/services/Alexandria_Boundaries/FeatureServer/0/query?outFields=*&amp;amp;where=1%3D1" target="_blank"&gt;https://services8.arcgis.com/AH8GuAfnCoO6STfX/arcgis/rest/services/Alexandria_Boundaries/FeatureServer/0/query?outFields=*&amp;amp;where=1%3D1&lt;/A&gt;",&lt;BR /&gt;title: "Workzones",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;renderer: NbhRender,&lt;BR /&gt;visible: true,&lt;BR /&gt;opacity: 0.3,&lt;BR /&gt;visibleAtMapScale: true,&lt;BR /&gt;minScale: 2000000,&lt;BR /&gt;maxScale: 0&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const nbhLabelClass = new LabelClass({&lt;BR /&gt;labelExpressionInfo: { expression: "$feature.Name" },&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "text", // autocasts as new TextSymbol()&lt;BR /&gt;color: "black",&lt;BR /&gt;font: {&lt;BR /&gt;weight: "bold",&lt;BR /&gt;size: 10&lt;BR /&gt;},&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;nbhLyr.labelingInfo = [ nbhLabelClass ];&lt;/P&gt;&lt;P&gt;map.add(nbhLyr)&lt;/P&gt;&lt;P&gt;//add legend&lt;BR /&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;visible: true,&lt;BR /&gt;font: {&lt;BR /&gt;size: 1&lt;BR /&gt;},&lt;BR /&gt;layerInfos: [{&lt;BR /&gt;layer: nbhLyr,&lt;BR /&gt;title: "Construction Status"&lt;BR /&gt;}]&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(legend,"bottom-left");&lt;BR /&gt;});&lt;BR /&gt;(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){&lt;BR /&gt;(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),&lt;BR /&gt;m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)&lt;BR /&gt;})(window,document,'script','&lt;A href="https://www.google-analytics.com/analytics.js','ga" target="_blank"&gt;https://www.google-analytics.com/analytics.js','ga&lt;/A&gt;');&lt;/P&gt;&lt;P&gt;ga('create', 'UA-98819163-1', 'auto');&lt;BR /&gt;ga('send', 'pageview');&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;BR /&gt;I have tried to add a div in the body that would hold the px amount and have the % amount in the viewDiv and multiple other approaches but nothing has worked so far.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 06:56:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-disappearing-on-html-page-when-sizing-is/m-p/1203619#M78313</guid>
      <dc:creator>RealzahAbbas</dc:creator>
      <dc:date>2022-08-17T06:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Map Disappearing on HTML page when Sizing is changed from pixels (px) to percentages (%)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-disappearing-on-html-page-when-sizing-is/m-p/1203624#M78314</link>
      <description>&lt;P&gt;Try with media query in your style tag,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;@media only screen and (min-width: 992px) {
    #viewDiv{
        height: 450px ;
        width: 600px ;
    }
}

@media only screen and (max-width: 600px) {
    #viewDiv{
        height: 200px ;
        width: 200px ;
    } 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 07:24:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-disappearing-on-html-page-when-sizing-is/m-p/1203624#M78314</guid>
      <dc:creator>JayakumarPD</dc:creator>
      <dc:date>2022-08-17T07:24:40Z</dc:date>
    </item>
  </channel>
</rss>

