<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9"> <title>mapMUSKEGO | mapVEPRASKAS</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css"> <style type="text/css"> html,body,#map{ padding:0; margin:0; overflow:hidden; height:100%; background-color:#dbddda; } </style> <script src="http://js.arcgis.com/3.8/"></script> <script> dojo.require("esri.map"); var map; var initExtent; var buttonclick; function init() { initExtent = new esri.geometry.Extent(2485078.859947771, 312461.2599477768, 2517629.6100261062, 344895.2419843375, new esri.SpatialReference({ "wkid": 32054 })); map = new esri.Map("map", { extent: initExtent, logo: false, slider: false}); var greyMAP = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer", { }); map.addLayer(greyMAP); } function buttoncall() { buttonclick = dojo.connect(map, "onClick", resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); } dojo.ready(init); </script> </head> <body> <div id="map"></div> <a href="javascript:buttoncall()" id="button1" ><img alt="button1IMG" id="button1IMG" style="bottom:10px; left: 10px; width:36px; position:absolute; z-index:22; border:none;" src="images/Button.png"/></a> </body> </html>
buttonclick = dojo.connect(map, "onClick", resultFunction);
<a href="javascript:buttoncall()" id="button1" ><img alt="button1IMG" id="button1IMG" style="bottom:10px; left: 10px; width:36px; position:absolute; z-index:22; border:none;" src="images/Button.png"/></a>
dojo.disconnect(buttonclick);
This should work for either one...Create a global variablevar buttonclick;Then create the function the button calls function buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }Give it a shot
var buttonclick;
function buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }
var buttonclick; function buttoncall() { buttonclick = dojo.connect(map, "onClick" resultFunction); } function resultFunction() { dojo.disconnect(buttonclick); alert("test"); }
Hi Jay,Here is an example that sets the infoTemplate each time the button is clicked.
<input type="button" id="button" value="Identify" />
on(dom.byId("button"), "click", function () { featureLayer.setInfoTemplate(template); initializeSidebar(app.map); on(app.map.infoWindow, "show", function () { featureLayer.setInfoTemplate(null); }) }) function initializeSidebar(map){ var popup = map.infoWindow; //when the selection changes update the side panel to display the popup info for the //currently selected feature. connect.connect(popup, "onSelectionChange", function(){ displayPopupContent(popup.getSelectedFeature()); }); //when the selection is cleared remove the popup content from the side panel. connect.connect(popup, "onClearFeatures", function(){ //dom.byId replaces dojo.byId dom.byId("featureCount").innerHTML = "Click to select feature(s)"; //registry.byId replaces dijit.byId registry.byId("leftPane").set("content", ""); domUtils.hide(dom.byId("pager")); }); //When features are associated with the map's info window update the sidebar with the new content. connect.connect(popup, "onSetFeatures", function(){ displayPopupContent(popup.getSelectedFeature()); dom.byId("featureCount").innerHTML = popup.features.length + " feature(s) selected"; //enable navigation if more than one feature is selected popup.features.length > 1 ? domUtils.show(dom.byId("pager")) : domUtils.hide(dom.byId("pager")); }); } function displayPopupContent(feature){ if(feature){ var content = feature.getContent(); registry.byId("leftPane").set("content", content); } }
require([ ], function( ) {
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.