ArcGIS API for Javascript 鹰眼开关问题 20
functionyykg(){alert(yingyan);if(yingyan==1){map.overviewMapDijit.hide();yingyan=0;}e...
function yykg(){
alert(yingyan);
if(yingyan==1){
map.overviewMapDijit.hide();
yingyan=0;
}else{
map.overviewMapDijit.Show();
yingyan=1;
}
}
这个函数有问题 哪里错了 这个思路不行的话 怎么实现鹰眼的开关呢
全部代码
<html>
<head>
<title> first map </title>
<link rel="stylesheet"href="http://js.arcgis.com/3.13/esri/css/esri.css">
<script src="http://js.arcgis.com/3.13/"></script>
<style>
#HomeButton {
position: absolute;
top: 95px;
left: 27px;
z-index: 50;
}
#mapDiv {
height:100% ;
width:100%;
}
#yykg {
position: absolute;
top: 150px;
left: 27px;
z-index: 50;
}
</style>
<script>
var map;
require(["esri/map","esri/dijit/HomeButton","esri/layers/ArcGISDynamicMapServiceLayer","esri/dijit/OverviewMap","esri/dijit/Scalebar"],
function(Map,HomeButton,ArcGISDynamicMapServiceLayer,OverviewMap,Scalebar) {
map = new Map("mapDiv", {});
var home = new HomeButton({map: map}, "HomeButton");
home.startup();
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://115.158.64.29/ArcGIS/rest/services/nanyangrail/MapServer",{});
map.addLayer(dynamicMapServiceLayer);
var overviewMapDijit = new OverviewMap({
map: map,
visible: true
});
overviewMapDijit.startup();
var scalebar = new Scalebar({
map: map,
scalebarUnit: "dual"
});
});
var yingyan=1;
function yykg(){
alert(yingyan);
if(yingyan==1){
map.overviewMapDijit.hide();
yingyan=0;
}else{
map.overviewMapDijit.Show();
yingyan=1;
}
}
</script>
</head>
<body>
<div id="mapDiv">
<div id="HomeButton"></div>
<input id="yykg" type="button" value="鹰眼开关" onclick="yykg()"/>
</div>
</body>
</html> 展开
alert(yingyan);
if(yingyan==1){
map.overviewMapDijit.hide();
yingyan=0;
}else{
map.overviewMapDijit.Show();
yingyan=1;
}
}
这个函数有问题 哪里错了 这个思路不行的话 怎么实现鹰眼的开关呢
全部代码
<html>
<head>
<title> first map </title>
<link rel="stylesheet"href="http://js.arcgis.com/3.13/esri/css/esri.css">
<script src="http://js.arcgis.com/3.13/"></script>
<style>
#HomeButton {
position: absolute;
top: 95px;
left: 27px;
z-index: 50;
}
#mapDiv {
height:100% ;
width:100%;
}
#yykg {
position: absolute;
top: 150px;
left: 27px;
z-index: 50;
}
</style>
<script>
var map;
require(["esri/map","esri/dijit/HomeButton","esri/layers/ArcGISDynamicMapServiceLayer","esri/dijit/OverviewMap","esri/dijit/Scalebar"],
function(Map,HomeButton,ArcGISDynamicMapServiceLayer,OverviewMap,Scalebar) {
map = new Map("mapDiv", {});
var home = new HomeButton({map: map}, "HomeButton");
home.startup();
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://115.158.64.29/ArcGIS/rest/services/nanyangrail/MapServer",{});
map.addLayer(dynamicMapServiceLayer);
var overviewMapDijit = new OverviewMap({
map: map,
visible: true
});
overviewMapDijit.startup();
var scalebar = new Scalebar({
map: map,
scalebarUnit: "dual"
});
});
var yingyan=1;
function yykg(){
alert(yingyan);
if(yingyan==1){
map.overviewMapDijit.hide();
yingyan=0;
}else{
map.overviewMapDijit.Show();
yingyan=1;
}
}
</script>
</head>
<body>
<div id="mapDiv">
<div id="HomeButton"></div>
<input id="yykg" type="button" value="鹰眼开关" onclick="yykg()"/>
</div>
</body>
</html> 展开
1个回答
展开全部
你的示例代码有大小写错误:show() 写成了Show()
如果仅仅是做个开关,当然是没有逻辑错误的,你碰到的问题可以再细化一下吗
如果仅仅是做个开关,当然是没有逻辑错误的,你碰到的问题可以再细化一下吗
更多追问追答
追问
额额 我从api上复制下来的 应该不是大小写的问题吧
yykg()这个函数是被调用了,alert出来变量yingyan的值了,可是鹰眼却没有隐藏
是不是map.overviewMapDijit.hide();这个有问题?该怎么改
追答
那就是api书写有可能出问题了。hide()和show()是平行方法,不可能一个大一个小的。如果是显示有问题就把Show()换成show()试试,如果是隐藏有问题就把hide()换成Hide()试试,应该是这点的问题。你可以尝试一下先。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询