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.

  • 相关阅读:
    TP5.1 遇见问题整理
    PDO 基础
    php7 连接 mysql 的两种方式
    [php] 添加接口访问日志(文件)
    curl 向远程服务器传输file文件
    VBoxManage
    linux 系统下安装多个php版本
    vim中文乱码问题
    vim 翻页命令
    php list()函数
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1959664.html
Copyright © 2011-2022 走看看