Custom mouse styles in different states of Arcgis for JavaScript

Source: Internet
Author: User

As the saying goes: the heart of beauty, people have it. Yes, yes, even if I was just a map, I wanted my map to look good. In this article, let's talk about how to customize the mouse style under ArcGIS for JavaScript.


First, say a few states. 1. Move the mouse over the map, 2, hold down the left mouse button to drag and drop the mouse, 3, pull the box to enlarge the map; 4, pull the box to reduce the map.

When the mouse is above the map;

Drag and drop the map while holding the mouse;

To enlarge the map when the frame is;

When the drop-box shrinks the map.


Next, talk about my idea of realization.

The first state, which appears when the map load is complete, is code:

Map.on ("Load", function () {     map.setmapcursor ("url (cursor/default.cur), Auto");});
The second state, when the map is dragged, you need to listen to map Mouse-drag-start and Mouse-drag-end events separately, the code is as follows:

Map.on ("Mouse-drag-start", function () {    map.setmapcursor ("url (cursor/pointer.cur), Auto");}); Map.on ("Mouse-drag-end", function () {    map.setmapcursor ("url (cursor/default.cur), Auto");});
In the third and fourth States, you need to define navigation, as follows:

var navtoolbar = new Esri.toolbars.Navigation (map);
These two states are triggered when the button is clicked and the code is as follows:

            On (Dom.byid ("zoom_in"), "click", Function (event) {//Pull box to enlarge                map.setmapcursor ("url (cursor/zoom-in.cur), Auto");                Map.on ("Mouse-drag-start", function () {                    map.setmapcursor ("url (cursor/zoom-in.cur), Auto");                });                Navtoolbar.activate (Esri.toolbars.Navigation.ZOOM_IN);            });            On (Dom.byid ("Zoom_out"), "click", Function (event) {//Pull box to zoom                out map.setmapcursor ("url (cursor/zoom-out.cur), Auto");                Map.on ("Mouse-drag-start", function () {                    map.setmapcursor ("url (cursor/zoom-out.cur), Auto");                });                Navtoolbar.activate (Esri.toolbars.Navigation.ZOOM_OUT);            });
Description:When both states are triggered, you also set the state at which the Mouse-drag-start is triggered.

Finally, everything returns to its original state after the operation, and the code is as follows:

            Navtoolbar.on ("Extent-history-change", function () {                navtoolbar.deactivate ();                Map.on ("Mouse-drag-start", function () {                    map.setmapcursor ("url (cursor/pointer.cur), Auto");                });            
Thus, in the above four states of the mouse State is controlled by our own style, the following is the complete code:

<! DOCTYPE html>
Source Download





Custom mouse styles in different states of Arcgis for JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.