arcgis.js controls the display range of the map body to automatically bounce back when it exceeds the area (implementation ideas)

arcgis.js controls the display range of the map body to automatically bounce back when it exceeds the area (implementation ideas)

background

A while ago, we encountered a problem in a company project. The map base map area only has a part of the range. If it exceeds the current range, a white background will be displayed, which is very bad in terms of usage effect. The accompanying requirements are that the map should be zoomed out, and when the mouse moves the map beyond the display range of the base map, the base map needs to rebound.

Effect

insert image description here

Ideas

1. arcgis.js controls its display range and automatically bounces back when it exceeds the base map display range. (1) After the map is created, use the listener event to listen to the map range change and call the shwoExtent method, which will pass the values ​​of the upper left and lower right corners of the map.

this.gisMap.on('extent-change',this.showExtent)

(2) Determine whether the current map display range exceeds the visible range of the map based on the full extent of the map's maximum display range. If it exceeds the range, the map's maximum range is displayed and the map rebounds.

Code snippet

// An highlighted block
let fullExtent = {
    xmin: xx,
    ymin: xx,
    xmax: xx,
    ymax: xx,
   }
showExtent(extS){
   let ext = extS.extent;  
    if (ext.xmin<this.fullExtent.xmin||ext.xmax>this.fullExtent.xmax||ext.ymax>this.fullExtent.ymax||ext.ymin<this.fullExtent.ymin) {
    let fullExtent = new esri.geometry.Extent(
     {
      ...this.fullExtent, 
      spatialReference:new esri.SpatialReference({ wkid: parseInt(4490) }) //SpatialReference sets the map coordinate system}
    );
    this.gisMap.setExtent(fullExtent);
   }
  },

Reference document: https://developers.arcgis.com/javascript/3/jsapi/extent-amd.html

Note: When consulting the documentation, you need to know what version of arcgis.js is used in the project.

This is the end of this article about arcgis.js controlling the display range of map bodies and automatically rebounding when the display range exceeds the area. For more relevant content about arcgis.js map display range, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • ArcGIS for js raster layer overlay (Raster Layer) problem
  • How to modify the infowindow style in arcgis for js
  • Realizing the effect of Baidu map ABCD marker based on ArcGIS for javascript

<<:  MySQL5.6.31 winx64.zip installation and configuration tutorial

>>:  Install and use Git and GitHub on Ubuntu Linux

Recommend

Stealing data using CSS in Firefox

0x00 Introduction A few months ago, I found a vul...

CSS to achieve zoom in and out close button (example code)

This effect is most common on our browser page. L...

Sample code for implementing music player with native JS

This article mainly introduces the sample code of...

Detailed steps for adding hosts you need to monitor in zabbix

Add monitoring host Host 192.168.179.104 is added...

Essential conditional query statements for MySQL database

Table of contents 1. Basic grammar 2. Filter by c...

How to customize more beautiful link prompt effect with CSS

Suggestion: Handwriting code as much as possible c...

Use of Linux bzip2 command

1. Command Introduction bzip2 is used to compress...

Linux cut command explained

The cut command in Linux and Unix is ​​used to cu...

Centos 7 64-bit desktop version installation graphic tutorial

If you think the system is slow and want to chang...

Linux installation apache server configuration process

Prepare the bags Install Check if Apache is alrea...

Detailed explanation of the construction and use of Docker private warehouse

The image can be saved on hub.docker.com, but the...

CSS implements Google Material Design text input box style (recommended)

Hello everyone, today I want to share with you ho...

Detailed explanation of docker entrypoint file

When writing a Dockerfile, include an entrypoint ...

Summary of several MySQL installation methods and configuration issues

1. MySQL rpm package installation # Download the ...