迎接4.0

前不久,esri官方发布了js4.0beta版本~第一时间尝鲜

官方介绍如下https://developers.arcgis.com/javascript/beta/guide/

抄一些过来

Overview

The 4.0 release of the ArcGIS JavaScript API has new cutting edge features, an improved developer experience, and a cleaner implementation that allows the API to continue to be a top-of-the-line web mapping API. It provides a cleaner and simpler API. In addition, 3D support has been implemented.

Looking Ahead

It is important to note that the existing 3.x API is still supported and being developed upon. 4.0 is a project in initial beta 1 phase. There are plans for multiple betas prior to releasing this as final.

Simpler API

The API provides a structured, streamlined method of creating web applications. For example: shorter and clearer class names, consistent casing, removal of confusing get/set property names and multiple constructors with various options.

NOTE: You can read more on this in the Discover 4.x topic.

3D support

Version 4.0 adds support for 3D (scenes). In addition to the SceneView mapping component, this also includes support for new layer types and new 3D symbology.

NOTE: You can read more on this in the Discover 4.x topic.

Technical Support

For beta 1, Esri will not provide support via the standard Technical Support channels. Please post your issues and questions on the GeoNet "4.0 beta" forum.

For feedback and questions, please post in the ArcGIS API for JavaScript forum and make sure to tag with "4.0beta".

To see forum posts by other, go to posts tagged as "4.0beta".

注意dojo版本

Discover 4.x

The 4.0 version of the JavaScript API consists of many underlying design changes and improvements. More about these fundamentals and detailed API changes can be found in the Migrating from 3.x to 4.0 topic. Two of the most notable changes are:

Simple and consistent API

The 4.0 version of the API introduces an improved developer experience with a cleaner implementation. With this comes changes to how a developer should plan their application's implementation.

The following breaks down some of the main points to consider when writing applications using the 4.x API.

Constructors and properties

For additional information on getting, setting, and watching properties, please refer to theWorking with properties topic.

All properties can be set within the constructor.

Prior to 4.x, many objects could be constructed in more than one way, using a number of different parameters in a specific order. This is no longer the case. Now there is only one constructor per class. Properties for a class can be set via its constructor or directly by the property itself. There is also no need to remember in which order the properties should be set.

This snippet sets the center point and scale directly in the MapView constructor.

view = new MapView({
  center: [-122, 38],
  scale: 12345678
});

This snippet sets an empty constructor and sets the center point and scale properties separately.

view = new MapView();     
view.center = [-122, 38];
view.scale = 12345678;

Watching property changes

The standard way of working with events and watching how a property changes, via a propertyname-changeevent is no longer the practice. In 4.x, you now just listen for when a specific property changes using the.watch() method.

More details on working with properties can be found in the Migrating from 3.x to 4.0 topic.

3D Support

Version 4.0 adds support for 3D (scenes). In addition to the SceneView mapping component, this also includes support for new layer types and new 3D symbology.

The Viewpoint and Camera classes are new in 4.0. The Camera provides the visible extent of a 3D view, whereas the Viewpoint describes the point of view for either a 2D or 3D View. It can do this by either:

  • Displaying an area by storing the extent of this area, or
  • Displaying the cartographic representation by storing information about the scale.

In a 2D view, the Viewpoint is determined using a center point and scale value, whereas the Camera position determines it for a 3D view. This is done because scale is treated differently between 2D and 3D views.

//This code snippet works in both 2D and 3D
var viewpoint = new Viewpoint({
  targetGeometry: new Point(4.4856, 48.3908),
  scale: 2000
});

view.animateTo(viewpoint);

3D symbology

3D symbology is new with 4.x. These symbol names contain "3D" and can be viewed within the API reference. Each 3D symbol may consist of several symbol layers. Because of this, a single graphic and/or geometry can be symbolized in multiple ways. Below is an example of two different types of 3D symbology.

3D Fill Symbol3D Object Symbol
3D fill symbology 3D object symbology

Dojo

Version 4.0 beta 1 of the ArcGIS API for JavaScript uses Dojo 1.10.4. dgrid version 0.3.17.

put-selector version 0.3.6 and xstyle version 0.1.3 are also included.

从3.x升级到4.0需要做的事情

Migrating from 3.x to 4.0

Version 4.0 is a substantial overhaul of the ArcGIS API for JavaScript and its mapping components. Consider rewriting applications instead of simply trying to update them.

This topic is designed to provide developers with existing apps using the 3.x API help in doing just this. Although there is a long list of updates made to the API, we have listed a few notable ones:

Significant changes were made in version 4.0. These changes were made to aid our developers in working more efficiently and effectively on whatever application they create. These changes can be seen in how constructors, properties, and events are handled.

Properties

Prior to 4.0, some properties could be get (read) or set (write) by callinggetMethodName or setMethodName. These types of methods are no longer needed as the API supports a simple and consistent way of getting and setting all properties.

  • Set the property directly on the object, for example map.basemap = 'oceans'.
  • Get the property directly from the object, for example map.basemap.title.

For example, in 3.x, setting a map's extent looks similar to,

map.setExtent(newExtent);

whereas the following line shows how to set a new map extent in 4.0,

map.extent = newExtent; 

Using 4.0, it is possible to use .get() to access deep properties similar to the following snippet,

var basemapTitle = map.get("basemap.title");

Watching property changes

Prior to 4.0, property changes were handled with events. In 4.0, watching for property changes has become much easier. This is handled via the .watch(property, callback)method. The callback is called each time the property changes and allows you to work with the property's new value, old value, and name along with the watched object.

var propertyChangeHandler = function(newValue, oldValue, property, object){  
  console.log("New Value: ",newValue," Old Value: ",oldValue,
  " Changed Property: ",property," Watched Object: ",object);
};  

Views

At 4.0, a Map can be displayed in 2D or 3D. Because of this, the drawing logic was revised. The Map and Layers no longer handle the drawing logic, instead it is now handled by Views.

Views are a concept introduced at version 4.0. A view can be one of two types:

  • MapView, applicable if working in 2D, or
  • SceneView, applicable if working in 3D

Views are used specifically to visualize the data within your map or scene. A map contains the actual data or layers to display, whereas the view handles displaying this data. How this data is visualized, or displayed, varies depending on whether you're working in 2D or 3D. The view has a reference to the map, e.g. view.map. But the map does not have a reference to the view. It is important to note that a single map can be consumed by multiple views.

Here's another way to think of this: the map describes the basemap and features in the world, whereas the view is the window to that map that allows it to be viewed.

The syntax below shows how to create and work with both a 2D view (MapView) and a 3D view (SceneView).

The following snippet shows 2D mapping using a MapView,

function (Map, MapView){
  map = new Map({
    basemap: "topo"
  });
  view = new MapView({
    container: "viewDiv",
    map: map,
    scale: 2400000
  });
}

This snippet shows 3D mapping using a SceneView,

function (Map, SceneView){
  map = new Map({
    basemap: "topo"
  });
  view = new SceneView({
    container: "viewDiv",
    map: map,
    scale: 2400000
  });
}

Map and layer specifics

Some significant updates were made to the Map and Layers; a few of these are listed below:

  • Starting with 4.0, the basemap is separated from the operational layers in the map.
  • It is also now possible to rotate a map, either in 2D or 3D.
  • Graphic layers can be added anywhere in a map's layer collection. Prior to 4.0, they always had to be on top of non-graphics layers.
  • A GroupLayer class has been added.

Module and package updates

See the module updates topic for details, below are a few notable ones:

  • Changed package names, e.g. esri/dijit is now esri/widgets/.
  • Shorter, clearer module names, e.g. ArcGISTiledLayer instead ofArcGISTiledMapServiceLayer.
  • Consistently cased module names, all modules now start with an uppercase letter.
  • Support classes have been moved into support folders to aid in keeping the API reference more organized, for example esri/layers/support and esri/tasks/support.
  • The structure of esri/config changed. The properties of esriConfig.defaults are now located in esriConfig. For example, to set the default geometry service:
// 3.x
esriConfig.defaults.geometryService = new GeometryService("http://yourdomain.com/geometryService");

// 4.x
esriConfig.geometryService = new GeometryService("http://yourdomain.com/geometryService");
  • The 3.x defaults.io object is now esriConfig.request.
// 3.x
esriConfig.defaults.io.alwaysUseProxy = true;

// 4.x
esriConfig.request.alwaysUseProxy = true;
  • The three *-all legacy modules have been removed. This is better handled in a build or using the web optimizer.
  • Constructors no longer support JSON, use the fromJson() method instead. For example,Graphic.fromJson(). (Note: Beta 1 still contains some constructors that use the 3.x style).
  • There are no graphics on the FeatureLayer. LayerView now renderers graphics representing features in FeatureLayer.

AMD only

Prior to 4.0, you could use both AMD and legacy modules. Beginning with 4.0, support is only provided for the AMD model.

Deprecation note

  • The Geocoder widget has been deprecated as of version 3.13. It is not part of 4.0. Please use the Search widget instead.
原文地址:https://www.cnblogs.com/feedback/p/4844299.html