zoukankan      html  css  js  c++  java
  • arcgis javascript api 学习4

    Mouse events on maps and graphics (map和graphics上的鼠标事件,准确的说是map和graphiclayer上的鼠标事件)

    The ArcGIS JavaScript API map and graphics layer provide a large set of mouse events users can use to interact with these objects(ArcGIS JavaScript API map和Graphiclayer提供了大量的鼠标事件,用户通过这些鼠标事件可以与这些对象交互). To register to listen to a map's onClick event:

    function init() {
      var map = new esri.Map(...);
      dojo.connect(map, "onClick", myClickHandler);
      map.addLayer(...);
    }
    

    When a user clicks the map, a mouse event is generated and all registered click handlers are called. The mouse event is passed as an argument to each handler. In addition to all properties populated by the browser, a mapPoint and screenPoint are included as properties of the event. The mapPoint represents the coordinates of the click in map coordinates and the screenPoint represents the coordinates of the click in screen coordinates.

    function myClickHandler(event) {
      alert("User clicked at " + event.screenPoint.x + ", " + event.screenPoint.y + " on the screen. The map coordinate at this point is " + event.mapPoint.x + ", " + event.mapPoint.y);
    }
    

    In addition to the mapPoint and screenPoint properties, the event returned includes a graphic property, which is the esri.Graphic object that received the event. The code below shows how you could handle the map's onClick event to report which graphic the user clicked. Notice that the listener for the onClick event will only be in effect after the map's onLoad event has fired. In this situation, a listener is dependent on another listener.

    function init() {
      var map = new esri.Map(...);
      dojo.connect(map, "onLoad", function() {
        dojo.connect(map.graphics, "onClick", myGraphicsClickHandler);
      });
    }
    
    function myGraphicsClickHandler(evt) {
      alert("User clicked on " + evt.graphic);
    }
    

    Since the Map.graphics object is only available to use after the Map.onLoad event is fired, you should wait to register event listeners until the the Map.onLoad event is fired.

    (因为map.graphics对象只有在map.onload事件触发以后才可用,所以你应该等待注册这个事件直到map.onLoad事件触发 //added by zhangjun at 2011-02-21 值得注意)

    ___________________________________________________________________________________________

    Next, use dojo.addOnLoad to specify an initialization function that will execute once the HTML is loaded(接下来,使用dojo.addOnLoad来指定一个初始化函数,这个初始化函数将在html加载后执行). In the initialization function, named init, the map is created and a new basemap layer is added to the map. The basemap layer is a service from ArcGIS.com.

  • 相关阅读:
    ionic2里面Angular2运用canvas画图
    前端css禁止复制页面上的文本
    原生JS检测浏览器安装的插件
    javascript 里面的 匿名函数自执行方法!
    软件质量保证体系是什么 国家标准中与质量保证管理相关的几个标准是什么?他们的编号和全称是什么?
    软件产品质量特性是什么?
    软件测试的策略是什么?
    软件测试分为几个阶段 各阶段的测试策略和要求是什么?
    软件测试各个阶段通常完成什么工作?各个阶段的结果文件是什么?包括什么内容?
    什么是软件测试?软件测试的目的与原则
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1959664.html
Copyright © 2011-2022 走看看