I am currenty working with ESRI API and what I am trying to do is when user insert id of portal page, div will refresh and load a new map.
Where I am stuck, variable which I am using change but changes did not show up
var konj = "9f91f911f58540ceaac0300c55e18fbb"//portal reference $(function(){ $("#buto").click(function(){ var bista = $("#inputField").val(); window.konj = bista; }); }); var map = new WebMap({ portalItem: { id: konj } }); var mapView = new MapView({ container: "mapViewDiv", map: map, padding: { top: 50, bottom: 0 }, ui: {components: []} });
<div class="calcite-map calcite-map-absolute"> <div id="mapViewDiv"></div> </div> <!-- Form --> <form id="nameForm"> <label class="my-1 mr-2" for="inlineFormCustomSelectPref">Please paste Id of map</label> <div class="form-row align-items-center"> <div class="col-auto"> <label class="sr-only" for="inlineFormInput">Id of map</label> <input type="text" class="form-control" id="inputField"> <br> </div> </div> <br> <button type="button" class="btn btn-primary" id="buto">Submit</button> </form>
If I type in console log variable name it is changed. But changes does not applied.
Ok, I come across this and forgot to put answer. This is how I solve it. Where mile in the end is assigned as mile1 so same function can work for new url over and over.
$("#buto").click(function(){ var bista = $("#inputField").val(); window.konj = bista; map.remove(mile); mile = new FeatureLayer({ url:bista }); map.add(mile); }); });
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.