2017-05-09 110 views
0

我想隱藏測量小部件。並希望在單選按鈕選中時顯示。但是當我隱藏它,它變得像這一點,並在單選按鈕沒有顯示點擊隱藏測量小部件和單選按鈕檢查顯示

enter image description here

這裏是我的代碼

var measurement = new esri.dijit.Measurement({ 
     map: map, 
     //measurement.hideTool("location") 
    // measurement.hideTool("distance") 

    }, dojo.byId('measurementDiv')); 

    measurement.startup(); 
    measurement.hide(); 
    measurement.hideTool("location"); 
    measurement.hideTool("distance"); 
    //measurement.hideTool("measurement Result"); 


<div class="roundedCorners" id="measureWindow" > 
    <div class="innerDiv roundedCorners"> 
     <div id="measurementDiv"></div> 
    </div> 
    </div> 

回答

1

那麼,據我所知,你想要顯示/隱藏基於單選按鈕點擊esri測量工具

下面是它 -

<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
 
    
 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> 
 
    <title>Measure Tool</title> 
 
    <link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/themes/calcite/dijit/calcite.css"> 
 
    <link rel="stylesheet" href="https://js.arcgis.com/3.20/esri/themes/calcite/esri/esri.css"> 
 
    <style> 
 
     html,body { 
 
     height:100%; 
 
     width:100%; 
 
     margin:0; 
 
     } 
 
     body { 
 
     background-color:#FFF; 
 
     overflow:hidden; 
 
     font-family:"Trebuchet MS"; 
 
     } 
 
     #map { 
 
     border:solid 2px #808775; 
 
     -moz-border-radius:4px; 
 
     -webkit-border-radius:4px; 
 
     border-radius:4px; 
 
     margin:5px; 
 
     padding:0px; 
 
     } 
 
     #titlePane{ 
 
     width:280px; 
 
     } 
 
     </style> 
 
    </head> 
 

 
    <body class="calcite"> 
 
    <div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline',gutters:false" 
 
    style="width:100%; height:100%;"> 
 
     <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"> 
 
     <!-- Radio Button container with CSS styles and positioning --> 
 
     <div style="position:absolute; right:20px; top:10px; z-Index:1000; color: white; margin-right: 20px; background: gray;"> 
 
     <input type="radio" data-dojo-type="dijit/form/RadioButton" checked='checked' name="measure" id="Show" value="Show"/> <label for="Show">Show</label> 
 
     <input type="radio" data-dojo-type="dijit/form/RadioButton" name="measure" id="Hide" value="Hide" /> <label for="Hide">Hide</label> 
 
     </div> 
 
     
 
     <!-- Measurement tool container with CSS styles and positioning --> 
 
     <div style="position:absolute; right:20px; top:40px; z-Index:999;"> 
 
      <div id="titlePane" data-dojo-type="dijit/TitlePane" data-dojo-props="title:'Measurement', closable:false, open:false"> 
 
      <div id="measurementDiv"></div> 
 
      
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
      <script src="https://js.arcgis.com/3.20/"></script> 
 
    <script> 
 
    var map; 
 
    require([ 
 
     "dojo/dom", 
 
     "esri/Color", 
 
     "dojo/keys", 
 
     "dojo/parser", 
 
     "esri/domUtils", 
 
     "esri/config", 
 
     "esri/sniff", 
 
     "dijit/registry", 
 
     "esri/map", 
 
     "esri/SnappingManager", 
 
     "esri/dijit/Measurement", 
 
     "esri/layers/FeatureLayer", 
 
     "esri/renderers/SimpleRenderer", 
 
     "esri/tasks/GeometryService", 
 
     "esri/symbols/SimpleLineSymbol", 
 
     "esri/symbols/SimpleFillSymbol", 
 
     "dijit/form/RadioButton", 
 
     "esri/dijit/Scalebar", 
 
     "dijit/layout/BorderContainer", 
 
     "dijit/layout/ContentPane", 
 
     "dijit/TitlePane", 
 
     "dijit/form/CheckBox", 
 
     "dojo/domReady!" 
 
     ], function(
 
     dom, Color, keys, parser, domUtils, 
 
     esriConfig, has, registry, Map, SnappingManager, Measurement, FeatureLayer, SimpleRenderer, GeometryService, SimpleLineSymbol, SimpleFillSymbol 
 
    ) { 
 
     parser.parse(); 
 
     //This sample may require a proxy page to handle communications with the ArcGIS Server services. You will need to 
 
     //replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic 
 
     //for details on setting up a proxy page. 
 
     esriConfig.defaults.io.proxyUrl = "/proxy/"; 
 
     esriConfig.defaults.io.alwaysUseProxy = false; 
 

 
     //This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications 
 
     esriConfig.defaults.geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); 
 

 
     map = new Map("map", { 
 
      basemap: "satellite", 
 
      center: [-85.743, 38.256], 
 
      zoom: 15 
 
     }); 
 

 
     var measurement = new Measurement({ 
 
      map: map 
 
     }, dom.byId("measurementDiv")); 
 
     measurement.startup(); 
 
     
 
     // code to hide measure tool 
 
     registry.byId("Hide").on("click", function(){ 
 
     domUtils.hide(registry.byId("titlePane")); 
 
     }); 
 
     
 
     // code to show measure tool 
 
     registry.byId("Show").on("click", function(){ 
 
     domUtils.show(registry.byId("titlePane")); 
 
     }); 
 
     
 
     }); // domUtils.show(widget); 
 
     
 
    
 
    </script> 
 
    </body> 
 
</html>

希望這將有助於你的工作代碼:)

0

您可能已經做到了這一點,但我會刪除啓動measurement.hidetool(「location」)並再次運行。如果沒有做任何事情,距離也是一樣。皮膚需要在那裏?這可能會掩蓋整個事情嗎?

+0

要隱藏的整個部件,然後想上顯示當單選按鈕檢查 –

+0

ooooh確定。這更有意義。我道歉。我認爲你需要一段時間聲明,指示該按鈕保持隱藏狀態,直到鼠標進入按鈕區域。有一個名爲.mouseenter()的jquery函數可能會有所幫助。這有幫助嗎?如果你還沒有答案,我應該能夠稍後再幫忙! – alexff7fan

+0

有沒有JavaScript解決方案?我希望小部件保持隱藏,直到單選按鈕被選中。 –