使用ArcGIS Server Javascript Api我遇到了在地图上显示主页按钮和地图概述的问题。因为什么原因主页按钮没有显示地图这是我的脚本是:
<script>
require([
"esri/map",
"esri/dijit/OverviewMap", "dojo/parser","dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"esri/dijit/HomeButton", "esri/layers/FeatureLayer", "dojo/dom-construct", "dojo/domReady!"
], function(
Map, OverviewMap,
parser, HomeButton, FeatureLayer
) {
parser.parse();
var map = new Map("mapDiv", {
basemap: "topo",
center: [-126.416, 55.781],
zoom: 6
});
//===================================================== Overview
var overviewMapDijit = new OverviewMap({
map: map,
visible: true
});
overviewMapDijit.startup();
//===================================================== Shapefile
//add a layer to the map
var featureLayer = new FeatureLayer("http://somewhere/1", {
mode: FeatureLayer.MODE_ONDEMAND,
});
map.addLayer(featureLayer);
//===================================================== Home Button
var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
});
</script>
和Home Button的CSS是:
#HomeButton { position: absolute; top: 120px; left: 50px; z-index: 2; }
你能告诉我为什么会这样吗?
答案 0 :(得分:1)
从我所看到的是你的“esri / dijit / HomeButton”模块加载到第6位,而在写function(Map, OverviewMap, parser, HomeButton, FeatureLayer)
时你已经在第4位提到了HomeButton参数位置。
如果您的模块也位于第4位
require([
"esri/map",
"esri/dijit/OverviewMap", "dojo/parser", "esri/dijit/HomeButton", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "esri/layers/FeatureLayer", "dojo/dom-construct", "dojo/domReady!"
]
以及功能在正确位置的所有参数,然后一切都应该顺利
另外,对于您在同一问题上的参考,您可以查看此how to correctly place import modules and corresponding parameters链接