我目前正在使用ESRI API,我正在尝试做的是当用户插入门户页面的id时,div将刷新并加载一个新地图。
我被卡住的地方,我正在使用的变量改变了,但是改变没有显示出来
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>
如果我键入控制台日志变量名,它就会更改。但是更改并不适用。
发布于 2018-06-24 21:39:30
好的,我遇到了这个问题,却忘了回答。这就是我解决问题的方法。其中,末尾的英里被指定为mile1,因此相同的函数可以一遍又一遍地为新的url工作。
$("#buto").click(function(){
var bista = $("#inputField").val();
window.konj = bista;
map.remove(mile);
mile = new FeatureLayer({
url:bista
});
map.add(mile);
});
});
https://stackoverflow.com/questions/50515351
复制相似问题