SuperMap iClient for Leaflet
This guide will quickly get you started on SuperMap iClient for Leaflet. You can get detailed interface parameters on the API page.
Preparing your page
Get Leaflet and SuperMap iClient for Leaflet
Leaflet and SuperMap iClient for Leaflet are needed for development. Among them, Leaflet includes CSS files and JS files. You can get these documents in the following ways:
Leaflet
- Download Leaflet.zip from Leaflet Official Website
- Download from Leaflet GitHub
SuperMap iClient for Leaflet
- Download the latest version from SuperMap iClient JavaScript Official Website
- Download the release version from SuperMap iClient for Leaflet GitHub
Import
Import files
When you get the file, you only need to import by <script> tags, just like ordinary JavaScript libraries. The following is detailed account of how to import Leaflet files online via CDN, and how to import SuperMap iClient for Leaflet through online sites.
Create a new HTML file, import Leaflet CSS file and JS file in < head> tag, and fill in BootCDN's hosting address, as follows:
Introduce the iclient-leaflet CSS file and JS file, and fill in the SuperMap iClient for Leaflet online site address:
npm
Before using this method, please check if the application Node.js is installed on your computer. If it is not installed, you can install it by downloading the installer . Then install SuperMap iClient for Leaflet by entering the following command on the command line:
If you need to use v11.1.1 or earlier versions, please install @supermap/iclient-leaflet.
The following is a description of how to use SuperMap iClient for Leaflet in npm projects.
Import the CSS files
Create a new HTML file and import the Leaflet CSS file and the iclient-leaflet CSS file into the <head> tag as follows:
Modular Development
ES6
You need to use npm to install dependencies before development, and then import the corresponding modules through ES6's import module loading syntax.
On demand
First, install @supermapgis/babel-plugin-import:
Then edit .babelrc:
Next, if you need TiledMapLayer, edit:
Note: import { SuperMap } from 'iclient-leaflet' will be deprecated
Import all modules
CommonJS
CommonJS is a JavaScript modular specification based on the Node.js environment. Use npm to install dependencies before development, and then introduce the corresponding modules via the require method.
Import partial modules
Import all modules
AMD
The following example uses the RequireJS library to implement; Download leaflet.js and iclient-leaflet.js through " Get Leaflet and SuperMap iClient for Leaflet " and place them in the directory where the entry master file specified by RequireJS is located.
Import all modules
CMD
The following example uses the SeaJS library to implement; Download leaflet.js and iclient-leaflet.js through " Get Leaflet and SuperMap iClient for Leaflet " and place them in the directory where the entry master file specified by SeaJS is located.
Import all modules
Package configuration
Because iClient uses ES6, to be compatible with browsers that do not support ES6 syntax, some configuration, including syntax conversion, needs to be done during the packaging process.
The packaged configuration here is for ES6 and CommonJS modular development, and for projects developed for AMD and CMD modules, there is no need to utilize packaging tools.
Take webpack4 as an example. Since the different package managers will cause the structure of the installation package to be different, the following examples describe the npm and cnpm configurations:
If you use npm install
or cnpm install --by=npm
to install dependencies, you need to add the following configuration items
in the webpack.config.js.
If you use cnpm install
to install dependencies, you need to add the following configuration items
in the webpack.config.js.
Compatible with IE 8
For better compatible with IE 8, except for leaflet.js, iclient-leaflet.js, you still need to introduce es5-shim.
You can directly download es5-shim.js and es5-sham.js
or refer the online addresss:
https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-shim.js
https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-sham.js
Add the following code before the <script> tab in the introduced leaflet.js:
Creating a map
Map published by SuperMap iServer
In the Preparing Your Page section, a new HTML page has been created, and continue to add code to create maps in the page, as follows:
Taking the world map published in SuperMap iServer as an example, add code to <script>, initialize map information:
Enjoy the result.
Third-party map
SuperMap iClient for Leaflet encapsulates a variety of Internet map information, such as Baidu maps, Tianditu, and so on. Taking the Tianditu as an example, SuperMap iClient for Leaflet provides tiandituTileLayer, codes as following:
Enjoy the result.
Setting map projection
SuperMap iClient for Leaflet can easily define map projections by the L.supermap.Proj.CRS projection class, and supports setting bounds, origin, scale array, and resolution array. For example:
For projections that are not supported or user-defined, you need to define key-value pairs through the Proj4js.defs[] static constant. Proj4js is a projection-related JavaScript script library. Please refer to the following website for details: https://trac.osgeo.org/proj4js/.
Currently, Proj4js supports following projections:
EPSG:4326 | EPSG:4269 | EPSG:3875 |
EPSG:4139 | EPSG:4181 | EPSG:3785 |
EPSG:4302 | EPSG:21781 | EPSG:102113 |
EPSG:26591 | EPSG:26912 | EPSG:27200 |
EPSG:27563 | EPSG:41001 | EPSG:4272 |
EPSG:42304 | EPSG:102067 | EPSG:102757 |
EPSG:102758 | EPSG:900913 | EPSG:GOOGLE |
A simple projection information is described as follows:
For parameter definitions of various projections, refer to https://spatialreference.org;If the definition exist, you can search and view its projection parameters, such as EPSG:21418, whose projection parameters are https://spatialreference.org/ref/epsg/21418/proj4/.
For a user-defined projection, you can create the projection by defining EPSGCODE and defs, where defs contains the reference projection parameters including name, projection, conversion to the WGS84 coordinate system (three parameters), major semiaxis, flatterning rate, original latitude, central meridian, standard parallels, east offset, north offset, Unit, etc.
Adding controls
By adding controls to the map, you can achieve interactive operations such as zooming in, zooming out, and layer switching. Commonly used controls:
Control | Class name | Introduction |
---|---|---|
Eagle-eye Map | L.control.minimap | The default is in the lower right corner of the map |
Zoom | L.control.zoom | The default is in the top left corner of the map |
Scale | L.control.scale | The default is at the bottom left corner of the map |
Layer switching | L.control.layers | The default is in the top right corner of the map |
Swipe | L.control.sideBySide | Swipe appears in the center of the map by default |
When adding a control, you should initialize the map first, and then add the control to the map via the addTo() method, for example:
Zoom control
Enjoy the result.
Layer switch control:
Enjoy the result.
Using vector tiles
Vector tiles organize and define vector data through different description files, analyze data in real time and complete rendering on the client. SuperMap iServer provides vector tile layers, namely new L.supermap.TiledVectorLayer(url, options).
- url:Map service address
- options:Layer optional parameter
Vector tiles example: using default style
Enjoy the result.
Drawing symbols and graphics
Basic drawing
For the Leaflet itself does not support the drawing of point, line and polygon, the plugin leaflet.draw.js needs to be imported. The import of plugin includes offline introduction and online introduction.
1. Offline introduction need to download leaflet.draw.js and then introduced by the <script> tag:
Download leaflet.draw.js from github, download address:
2. <script> Label import:
Online introduction can import the required plugins via the CDN into the <script> tag:
When imported the plugin, the point, line and polygon drawing function is implemented by the following code:
Enjoy the result.
Capture drawing
Capture drawing means that the mouse enters a certain tolerance range of an already drawn point when drawing, and the mouse is absorbed to the position of the already drawn point.
The Leaflet itself does not support point, line and polygon capture drawing. It is necessary to import leaflet-geoman plugins.
1. Import in <link> and <script> Tag:
2. After the plugin is introduced, the point capture drawing function is implemented by the following code:
Enjoy the result.
Area and distance measurement
SuperMap iClient for Leaflet supports area and distance measurement.
Distance measurement
Here are the steps to create distance measurement function:
1. Construct service parameter class
The measurement service parameter class provides the information required by the service request, which provides the query parameter encapsulation of the measurement. Parameters provided include geometry and unit, which are used to define the geometric objects and units of the measurement, with the code as follows:
2. Construct the service class and send the request
The measurement service class is responsible for sending requests to the server and getting the query results returned. The service class needs to specify service parameters such as URL, send request information to the server, and then request the complete event via the listener service. The results can be obtained from the event service data class, and handled according to the requirements. Please refer to the following code:
Enjoy the result.
Area measurement
1. Instantiate the measurement service constructor. The code is as follows:
2. Call the measurement function
Call the measurement function and get the return result, the code is as follows:
Enjoy the result.
Feature query
The feature query functions supported by SuperMap iClient for Leaflet mainly include:
- Query by specifying ID
- Query by specifying SQL conditions
- Query by specifying rectangle bounds
- Query by specifying arbitrary geometric range
- Distance query
- Buffer query
- Query grid information
- Query field information
Query by specifying ID
Query geographic features with specified IDs in a dataset and display the results on the client. This example queries geographic features with specified IDs in the World dataset.
Using the interface L.supermap.FeatureService to query geospatial features with IDs 233 and 234 in the dataset "World:Countries".
Enjoy the result.
Query by specifing SQL conditions
Specify SQL query queries geographic vector features satisfying a specified SQL conditions in a dataset and display the results on the client. This example queries geographic features with specified SMID in the World dataset.
Use the interface L.supermap.FeatureService to query the vector elements of "SMID=234" in the dataset "World:Countries".
Enjoy the result.
Query by specifying rectangle bounds
Rectangle bounds query is to find vector feature that fits the rectangle bounds in specified dataset collection and displays results in the client. This example is: Querying features in the World Data Service for a specified scope of rectangles.
Use the interface L.supermap.FeatureService to find the vector features in the dataset "World:Capitals" that match the scope of this rectangle.
Enjoy the result.
Query by specifying arbitrary geometric range
Geometric range query is to find vector features in the specified dataset collection that match the geometric scope and displays the result in the client. This example is: Querying features of arbitrary geometric range in the World Data Service.
The interface L.supermap.FeatureService uses intersected spatial query patterns in the "World:Countries" dataset to query vector elements that conform to the geometric range.
Enjoy the result.
Distance query
Distance query, which finds a vector feature that meets the certain distance requirement in specified layer in the map service, and displays results in the client. This example is: Querying vector features that match distances requirement in the World Maps service.
Use the interface new L.supermap.QueryService to find the vector feature in the layer "Capitals@World.1" whose distance from the specified point is 10 degrees (map coordinate units).
Enjoy the result.
Buffer query
Buffer query is to find vector elements that match the buffer requirement in a specified set of datasets in the data service, displays it in the client. This example is: Querying the features of the specified buffer in the World Data Service.
Use the interface L.supermap.FeatureService to find the vector elements whose buffer range is 10 degrees (map coordinate units) in the dataset "World:Capitals".
Enjoy the result.
Query grid information
Query grid information is find the pixel value information corresponding to a geographical location in the specified dataset and display it in the client.
Use the interface L.supermap.GridCellInfosService to to query grid information in the dataset "WorldEarth". The sample code is as follows:
Enjoy the result.
Query field information
Query field information is find the vector elements with specified information in the specified dataset collection, and display them in the client. This example is: Querying the features of the specified field in the World Data Service.
Use the interface L.supermap.FieldService to query the field information of the field "SmID" in the dataset "continent_T". And count SmID in the dataset to find the average, maximum, minimum and so on.
Enjoy the result.
Feature editing
Feature editing, including the editing of points, lines, polygon, etc., such as line type, color, line width, etc. If you don't have a custom style set, the interactive controls would drawn with the default style.
Use the interface L.supermap.FeatureService to add feature information to the dataset "Capitals".
Enjoy the result.
Thematic map
In cartography, those map that highten one or more elements or phenomena, and concentrates on representing one theme is called a thematic map. In SuperMap, the thematic map is a symbolic display of the map layer which graphically represents a certain aspect of the feature element using various graphic rendering styles (size, color, line type, fill, etc.). The thematic map can be created directly based on the API of the GIS client, or it can be created by the GIS server by invoking the back end map service. The way of making thematic map by the server side has relatively higher performance and higher efficiency of drawing; the thematic maps produced by the client can introduce the latest front-end technology to achieve more intuitive and beautiful display effects and interactive effects.
Server thematic map
The server thematic map is made by the server is the client sends the parameters to the server, such as the name of the dataset, the style and so on. The server makes the theme map according to the parameters, returns the map to the client, and displays it by the client.
Taking the dot density thematic map as an example.
The dot density thematic map uses the same point of certain size and shape to represent the distribution of the phenomenon, the quantitative characteristics and the distribution density. The number of points and the meaning they represent are determined by the content of the map. The dot density thematic map uses the number or intensity of points to reflect the theme values corresponding to a region or range.
Running result
Client thematic map
The client thematic map is performing corresponding calculations on the client based on the shape and attribute of the data, and assigns different drawing styles through the feature layer or any layer and displays the thematic map on the client.
The thematic map supported by SuperMap iClient for Leaflet include:
- Unique thematic map
- Range thematic map
- Graduated symbols thematic map
- Label thematic map
- Chart thematic map
Unique thematic map
Projects the factors with the same theme value as a category, sets a rendering style for each category, such as color or symbol, the factors with the same theme value are in the same rendering style, to distinguish between different categories.
The following codes shows how SuperMap iClient for Leaflet build a unique thematic map object:
The code of Unique thematic map type and color configuration is as follows:
Enjoy the result.
Range thematic map
In the range thematic map, theme values are divided into multiple range items in accordance with a range mode, and factors are assigned to one of the range items according to their theme value, the factors in the same range item use the same color, filling, symbol style etc, to display. The theme variable based by range thematic map must be numeric, range thematic map is commonly used to reflect the amount or degree characteristics of continuous distribution phenomenon, such as the distribution of precipitation, the distribution of soil erosion intensity, etc.
SuperMap iClient for Leaflet implements the range thematic map by the following code:
Enjoy the result.
Graduated symbols thematic map
The graduated symbols thematic map is represented on the map by a set of grade symbols according to a certain number of characteristics of each element based on certain classification method, so as to present the quantity relative relationship between the elements.
SuperMap iClient for Leaflet implements the graduated symbols thematic map by the following code:
Enjoy the result.
Label thematic map
Some marking is essential to the map, not only to help users to better distinguish the features, but also to show some important attributes of the features, such as administrative divisions, rivers, organs, names of tourist attractions, elevation of the contour lines, etc. In SuperMap, users can easily implement map annotation by making label thematic map.
The mainly code that SuperMap iClient for Leaflet used to implement the label thematic map is as follows:
Enjoy the result.
Statistics thematic map
Statistics thematic map reflect the size of their corresponding theme values by drawing statistics graphs for each factor or record. The statistics thematic map can be based on multiple variables, reflecting multiple attributes is the values of multiple thematic variables can be plotted on a statistics graph. Statistics thematic maps can be used to form horizontal and vertical comparisons between regions themselves and each region. It is usually used in maps with relevant quantitative characteristics, such as grain output, GDP and population of different regions for many years, and passenger volume and subway flow at different times.
In a statistics thematic map, each region has a statistical graph showing the value of each theme in the region. There are many forms of representation. Currently available types are: histogram, line chart, 3D column chart, dot chart, pie chart, ring chart.
The mainly code that SuperMap iClient for Leaflet used to implement the statistics thematic map is as follows:
Enjoy the result.
Spatial analysis
Spatial analysis is a spatial data analysis technology based on the location and morphological features of geographic objects. The purpose of spatial analysis is to extract and transmit spatial information. The spatial analysis functions supported by SuperMap iClient for Leaflet include:
- Buffer analysis
- Thiessen polygon
- Overlay analysis
- Mini distance calculation
- Surface analysis
- Dynamic segmentation
- Route calculate measure
- Route locator point
- Route locator line
- Interpolation analysis
- Grid algebraic calculation
- Terrain slope calculation
- Terrain aspect calculation
- Terrain curvature calculation
- Terrain cut and fill calculation
- Kernel density analysis
Buffer analysis
Buffer analysis is an analytical method that automatically establishes a range of regions of a certain width based on the specified distance around the point, line, and polygon features. For example, in environmental governance, a certain width is often drawn around polluted rivers to indicate contaminated areas. At airports, a range of areas are often zoned around a non residential area due to health needs.
Here we create a round buffer with the buffer radius of 10 meters around a road for Changchun data.
Set parameters for buffer analysis, set buffer analysis common parameters
Set the buffer analysis service object, which is used to pass parameters specified at the client side to the server side and receive the data from returned from the server. When a request has been sent to the server and the server has returned the result successfully, the user can handle the results of buffer analysis from the server.
Enjoy the result.
Thiessen polygon
Dutch meteorologist A.H.Thiessen proposed a method of calculating average precipitation based on the precipitation measurements at discretely distributed meteorological stations. In the method, all the neighboring stations are connected to form a series of triangles. Then the perpendicular bisectors of the triangle sides can be drawn. For each station, the bisectors surrounding it form a polygon. The precipitation in the polygon region can then be represented by the precipitation measured at that station, which is also the only station within the polygon. This polygon is named Thiessen polygon. The Thiessen polygon, also known as the Voronoi diagram, consists of a set of continuous polygons that form a vertical bisector that connects the lines of two adjacent points.
The characteristics of Thiessen polygons:
- Every Thiessen polygon contains only one discrete point;
- For any location in a Thiessen polygon, the discrete point associated with that polygon is the closest one among all the discrete points;
- The points located on a side of a Thiessen polygon have equal distance to the two discrete points defining that side.
The interface of the Thiessen polygon is used as follows:
Taking the dataset Thiessen polygon as an example, the Thiessen polygon service object is set up to pass the client's Thiessen polygon service parameters to the server, and receive the result data of the Thiessen polygon analysis returned by the server.
Enjoy the result.
Overlay analysis
Overlay analysis is a very important spatial analysis function in GIS. It refers to the process of generating new datasets through a series of set operations on two datasets under the unified spatial Reference system, which aims to extract the new spatial geometry information needed by the user via processing or analyzing spatial data. At the same time, the various attribute information of the data will be processed by the overlay analysis.
At present, overlay analysis is widely used in resource management, urban construction assessment, land management, agriculture, forestry, animal husbandry, statistics and other fields. The role of overlay analysis in various fields:
- Resource management is mainly used in the fields of agriculture and forestry to solve the problems of distribution, change and statistics of various resources.
- Urban construction assessment should be used to analyze the development and change of urban population, economy and construction, and the trend and law of the change.
- Land and cadastre management involves the change of land use nature, the change of plot boundary and the change of cadastral ownership, which can be accomplished efficiently with high quality under the help of GIS overlay analysis.
- Ecological and environmental management evaluation is used for regional ecological planning evaluation, environmental status assessment, environmental impact assessment, pollutant reduction and allocation of decision-making support, etc.
- Geoscience research and application is used for topographic analysis, watershed analysis, land use research, economic geography research, spatial statistical analysis, cartography, etc.
Here we overlay the administrative boundary of Beijing and Tianjin area and that of neighboring areas.
Set overlay analysis parameters
Set the overlay analysis service object, which is used to pass parameters specified at the client side to the server side and receive the data from returned from the server. When a request has been sent to the server and the server has returned the result successfully, the user can handle the results of overlay analysis from the server.
Enjoy the result.
Min distance calculation
The calculation of min distance is calculating the min distance between features in the calculated dataset to features within the query bounds of the reference dataset. Currently, only 2D point dataset is supported for calculated dataset. The reference dataset can be 2D point, line, region or 2D network dataset.
Here we find the closest geometric object to a point in Changchun data.
Enjoy the result.
Extract isolines/isoregions
Surface analysis includes extracting isolines and extracting isoregions. Isolines are lines connected with adjacent points with same values, commonly used for contour lines for height, depth, temperature, precipitation, etc. The distribution of isolines reflects the change of the value on the grid surface, and the denser the contour lines are, the more drastic the change of the grid surface values. At places where the contour distribution is sparse, the change of grid surface values is smaller. By extracting isolines, we can find places where the elevation, temperature or precipitation is the same. Meanwhile, the distribution of isolines can also reflect where the value change is steep or gentle. The isoregions is composed by closing adjacent contour lines. The change of the isoregions can intuitively indicate the change between adjacent isolines, such as elevation, precipitation, temperature or atmospheric pressure. Places where the elevation, precipitation or temperature is equivalent can be obtained by extracting the isoregions.
This section will introduce the usage of surface analysis interface by extracting contour lines based on temperature resample points of China.
Set surface analysis parameters
Set the surface analysis service object, which is used to pass parameters specified at the client side to the server side and receive the data from returned from the server. When a request has been sent to the server and the server has returned the result successfully, the user can handle the results of surface analysis from the server.
Enjoy the result.
Dynamic Segmentation
Dynamic segmentation technology is based on the traditional GIS data model, using linear reference technology to realize the dynamic display, analysis and output of attribute data on the map. It is an important technical means in GIS spatial analysis. It is not a physical segmentation of the online feature along a certain attribute of the line. Instead, it uses the idea and algorithm of the linear reference system based on the traditional GIS data model to store the changes along the attribute as independent attributes table field (event attribute table); In the analysis, display, query and output, the linear elements are dynamically logically segmented according to the distance values in the event attribute table, and the relative position description is used to generate events on the line, which is easier to locate than the traditional GIS elements. In addition, the technology also improves data production efficiency and data storage space utilization, reducing the complexity of data maintenance. It has been widely used in public transportation management, road quality management, navigation line simulation, communication network management, power grid management and many other fields.
This section introduces to you how to show the road traffic (blocked/congested/expedite) in real-time on the client side based on dynamic segmentation technology to prompt motorists to avoid entering the congested road and choose the appropriate route using data for Changchun city road map as the sample data. The usage of the dynamic segmentation interface is as follows:
Set parameters including DataReturnOption and generateSpatialDataParams for dynamic segmentation on the client side.
Set the dynamic segmentation service object, which is used to pass parameters(generateSpatialDataParams) specified at the client to the server and receive the data returned from the server. When a request has been sent to the server and the server has returned the result successfully, the user can handle the results of dynamic segmentation from the server. The road condition information in the spatial data is presented to the user in the form of thematic map.
Enjoy the result.
Route calculate measure
Route Calculate Measure calculates the M-value of a point to the starting point of the route. For example, a user may want to know where an accident occurred to determine the distance of the point from a certain intersection.
Here we calculate the distance from an accident point to the road intersection (route ID 1690). The sample data used is Changchun data.
The usage for the interface of Route Calculate Measure Service is as follows:
After the map loading is completed, we will perform the Route Calculate Measure operation. First, we need to get the route object according to the RouteID, and then proceed to subsequent operation.
Enjoy the result.
Route locate point
Route Locator Point determines the point according to the M value. The application scenario is opposite to Route Calculate Measure. It will be used to determine the precise coordinates of an accidient position on the premise of the M value from the point to the road intersection.
Here we will determine the precise coordinates of an accidient position on the premise of the M value from the point to the road intersection is 200 meters on the route with the ID of 1690. The sample data used here is Changchun data, the usage of Route Locator Point interface:
After the map loading is completed, we will perform the Route Locator Point operation. First, we need to get the route object according to the RouteID, and then proceed to subsequent operation.
Enjoy the result.
Route locate line
Route Locator Line determines the line object on the route according to the specified range. For example, you need to know the precise position of a line segment when we know there is a line segment blocked.
Here we introduce how to determine precise position of a line segment on the premise of the measure values of the line segment to the road intersection are 10 meters to 800 meters.
After the map loading is completed, we will perform the Route Locator Line operation. First, we need to get the route object according to the RouteID, and then proceed to subsequent operation. The usage for the interface of Route Locator Line Services is as follows:
Enjoy the result.
Interpolation analysis
Interpolation analysis can predict the numerical conditions around the sampling point by interpolating the finite sample point data, so as to master the overall distribution of the data in the study area, the discrete points not only reflect the numerical conditions of their location, but also reflect the numerical distribution of the region. Three kinds of interpolation methods are provided in SuperMap: Inverse Distance Weighted(IDW), Kriging interpolation square (Kriging), Radial basis function interpolation (RBF). The chose of interpolation analysis usually depends on the distribution of sample data and the type of surface to be created.
No matter which interpolation method is chosen, the more data and the wider the distribution of known points, the closer to the actual situation the interpolation results will be. The following is the example of the Inverse Distance Weighted(IDW).
Enjoy the result.
Grid algebraic operation
Grid algebraic operation idea is to use algebra view of characteristics of geographical phenomena and spatial analysis. Essentially, it conducts the mathematical operation and functional operation for multiple raster datasets. The pixel value of the result raster data is obtained by algebraic operation from the pixel value of the same position of one or more input raster data.
In order to better implement the function of raster algebra, SuperMap provides a wealth of operators, functions and operation expressions, in addition to commonly used arithmetic operations (such as plus, minus, multiply, divide, toInt and toFloat), also supports users-defined expressions for raster arithmetic, conditional operations, logic operations, function operations (including common functions, trigonometric functions, etc.) and compound operations, users can achieve a variety of raster analysis needs through raster algebra operations.
The interface of grid algebraic operation is used as follows
Enjoy the result.
Terrain slope calculation
Slope is one of the important terrain factors, in which slope denotes the measurement of the ratio of height change of a certain location on the earth surface. Terrain slope calculation is used to calculate the slope value of each pixel in the raster dataset. The bigger the slope value, the steeper the terrain; on the contrary, the smaller the slope value, the flatter the terrain.
In SuperMap, slope calculation provides three ways to denote, including degrees, radians and percentages. Because there is no practical significance to calculate the slope and aspect of point, the method calculates the mean value of the slope of each pixel in a raster dataset.
Here we calculate the slope value of each pixel in Jingjin data. The map needs to be initialized before the terrain calculation process. The terrain slope calculation analysis is performed after the map is loaded.
Enjoy the result.
Terrain aspect calculation
Aspect is one of the important terrain factors, in which aspect denote the measurement of slope direction variation of a certain location on the earth surface. Terrain aspect calculation is used to calculate the aspect of each pixel in the raster dataset. Aspect is represented in degrees, the range of aspect analysis result is 0° to 360°. Starts form due north 0° and moves clockwise and ends at 360°. flat slope has no direction and the value is -1.
Here we calculate the aspect value of each pixel in Jingjin data. The map needs to be initialized before the terrain calculation process. The terrain aspect calculation analysis is performed after the map is loaded.
Enjoy the result.
Terrain curvature calculation
Terrain curvature calculation is used to calculate the curvature of the surface of the raster data. Curvature is the second derivative of the surface, or it can be called the slope of the slope, which is one of the main parameters to express topographic surface structure. The output is the surface curvature of each cell of the terrain raster, which is obtained by fitting the cell to eight adjacent cells. The resulting output is a raster dataset with output curvature types: mean curvature, profile curvature, and plane curvature, the mean curvature is the necessary output, and the profile curvature and plane curvature are selectable outputs. Wherein, the curvature of the profile refers to the curvature along the direction of the maximum slope, and the curvature of the plane refers to the curvature perpendicular to the direction of the maximum slope.
Elevation scaling factor: when calculating curvature, the unit that requires the grid value of the terrain (the elevation value) is the same as that of the X, Y coordinates, and usually requires the elevation value multiplied by a height scaling coefficient, which makes the three units consistent. For example, the units in the direction of X and Y are meters, while the units in Z direction are feet. As 1 feet are equal to 0.3048 meters, the scaling factor is 0.3048. If set to 1, the representation is not zoomed.
The map needs to be initialized before the terrain curvature calculation process.
The terrain curvature calculation analysis service is performed after the map is loaded.
Enjoy the result.
Terrain cut and fill calculation
The objects on a surface may move because of deposition and erosion, the result is the increasing of surface objects at some region and the reducing of surface objects at other region. In project, the reducing of surface objects is called Cut and the increasing of surface objects is called Fill. We can calculate the area and volume of cut and fill when one situation change to another.
Here we calculate the area and volume of cut and fill in Jingjin data.
Enjoy the result.
Kernel density analysis
Kernel density analysis: used to calculate density per unit of the point, line feature measurement value in the specified neighborhood. In simple terms, it can visually reflect the distribution of discrete measurements over successive regions. The result is a smooth surface with big values in the center and small values around. The grid value is the density and is reduced to 0 at the boundary of the neighborhood.
Kernel density analysis can be used to calculate population density, building density, access to crime reports, population monitoring of tourist areas, chain stores operating analysis and so on. For example:
A number of high-rise apartments and houses are distributed in a certain block, the number of people in each building is known, this function can be used to obtain the population distribution in the area. This is equivalent to distributing the population of each building into the specified circle neighborhood with the change trend of the Kernel function, and the overlapping areas are summed to obtain the population density throughout the neighborhood. The population density results can be used for store location decision, crime rate estimation, etc.
Before performing kernel density analysis, you need to initialize the map.
The kernel density analysis service is performed after the map is loaded.
Enjoy the result.
Traffic transfer analysis
The use of traffic transfer analysis is as follows:
- Define the query function for the start site and end site;
- Add traffic transfer query funciton. It is necessary to set a traffic transfer parameter for sending to the server on the client, and define a traffic transfer service for sending a request to the server and obtaining the traffic transfer result data from the server. Finally the returned results are displayed on the client.
Taking the bus route data simulated by Changchun traffic data as an example. The example is from "省汽修" to "中安大厦", the transfer method is the least time. Users can choose the most suitable travel route according to his own needs.
1. Query traffic transfer plan
This method returns all the ride plans, and users can obtain a specific ride route according to the introduction information in the plan. Firstly, set the traffic transfer parameters, including solutionCount, transferTactic, walkingRatio, points. Define the traffic transfer service function, send a request to the server, and wait for the server to successfully process and return the result.
2. Query driving route
Get detailed information about a particular route based on the ride plan obtained from the transfer results(transfersolution).
Enjoy the result.
Here is the result of the least time query, in which the departure station is "省汽修" and the destination is "中安大厦". The effect is as follows:
Network analysis
SuperMap iClient for Leaflet supports:
- Service area analysis
- Closest facility analysis
- Location-allocation analysis
- Multi-traveler analysis / logistics distribution
- Best route analysis
- Connected edges analysis
- TraceUp and traceDown analysis
Service area analysis
The service area analysis is to find the service scope for the designated service center point on the network. For instance, the 30-minute service area for a certain point on a network, the time from any point in the service area to that point will not exceed 30 minutes.
Taking Changchun data as an example, select the service center point to be analyzed in the map (support multi-center), perform buffer analysis according to the incremented values of 400, 500, 600... as the service radius according to the order of selected service center points. That is, the service radius of the first service center point is 400, the service radius of the second service center point is 500, and so on.
Service area analysis interface usage:
Set the parameter findServiceAreasParams, including network analysis common parameters, route sites, and so on.
Define the service area analysis service object. The service area analysis object is used to pass the service area analysis parameters(findServiceAreasParams) set by client to server, and receive the dynamic segmentation analysis result data returned by the server. When the request is sent to server and the server successfully returns the result, users can process the obtained service area analysis result accordingly.
Enjoy the result.
Closest facility analysis
Closest facility analysis is to give an incident and a set of facilities on a network, to find one or several facilities that can be reached with minimum cost for incident, and the results show the best path, cost, and direction of travel from the incident to the facility or from the facility to the incident. For instance, you can set up a closest facility problem to search for hospitals within a 20-minute drive of the site of an accident. Any hospitals that take longer than 20 minutes to reach are not included in the results. In this case, the accident is the incident and surrounding hospitals are facilities. Closest facilities analysis is actually a path analysis. Therefore, it is also possible to apply the settings of the obstacle side and the obstacle point. These obstacles will not be traversed on the road and will be considered in the path analysis.
Taking Changchun data as an example, mark the incident on the map, and then perform closest facilities analysis for the three hospitals.
Set the parameters, including network analysis general parameters, incident, facilities, search radius, etc.
Defines closest facility analysis object, which is used to pass the latest facility lookup analysis service parameters set by the client to the server, and receives the latest facility analysis result returned by the server. When the request is sent to the server and the server successfully returns the result, the user can process the obtained closest facility analysis result accordingly.
Enjoy the result.
Location-allocation analysis
Location-allocation analysis is to determine the optimal location of one or more facilities to be built so that the facility can provide services or goods to the demanding party in the most cost-effective manner. The location-allocation analysis is not only a site selection process, but also the demand point needs to be allocated to the service area of the corresponding new facility, so it is called site selection and allocation.
Set location-allocation analysis parameters, including traffic network analysis common parameters, route sites, etc.
Define the location-allocation analysis service object, which is used to pass the location zoning analysis service parameter set by the client to the server, and receive the dynamic segmentation analysis result data returned by the server. When the request is sent to the server and the server successfully returns the result, the user can process the obtained closest facility analysis result accordingly.
Enjoy the result.
Multi-traveler analysis / logistics distribution
Multi-traveler analysis, also known as logistics distribution, is to find M distribution center points and N delivery destinations (M, N is an integer greater than zero) in the network dataset, find a cost-effective delivery path, and give The corresponding walking route. The multi-traveler analysis function is to solve how to properly distribute the delivery order and delivery route, to minimize the total cost of distribution or to minimize the cost per distribution center.
The results of the multi-traveler analysis will give the delivery destinations that each distribution center is responsible for, and when a distribution center delivers the goods to its responsible delivery destination, It also gives the order through the various delivery destinations, and the corresponding walking routes, thereby minimizing the distribution cost of the distribution center or minimizing the total cost of all distribution centers.
Taking Changchun data as an example, you can analyze the distribution routes of various warehouse distribution centers of food factories to user-designated retail stations through multi-traveler analysis and traveler analysis, and get the shortest route that taken by quality inspectors when check the goods at each retail station.
Set the parameter findMTSPPathsParams, including network analysis common parameters, distribution center point collection, distribution target point collection, distribution mode, etc.
Submit the request parameters of the logistics distribution analysis to the server. After the server successfully processes and returns the results, the user can obtain the best route for the goods to be delivered to the respective delivery destinations by the distribution center in turn.
Enjoy the result.
Best path analysis
The best path analysis is to solve the path with the least impedance between the two points in a network, and the nodes in the network must be accessed according to the order of selection of the nodes. There are many understandings of “minimum impedance”, such as the shortest time, the lowest cost, the best scenery, the best road conditions, the least bridges, the least toll stations, and the most rural areas based on single factor considerations, etc.
Let's take the Changchun data as an example to calculate the best path between the places in the map that will walk.
Set the parameter findPathParams, including network common parameters, route sites, etc.
Submit the request for the best path analysis to the server. After the server to successfully process and return the best path analysis result, the serviceResult will parse it, and display the driving route in the map and give the driving guidance information.
Enjoy the result.
Conneted edges analysis
The network may not be fully connected in the real world. You can use connected edges analysis to determine which points/edges are connected with some others. Connected edges analysis does not need to consider the network impedance, and the difference between the network elements is the state of connectivity (connected or disconnected).
Here we query the connected or disconnected roads in Changchun data.
Set the connected edges analyst parameters, including whether to query the connected or disconnected arcs, analyze the return result, and so on.
Send a tracing analyst request to the server and recieve the returned analysis result.
Enjoy the result.
TraceUp and traceDown analysis
TraceUp and traceDown analysis starts from a node according to a specified rule, and then search all the arcs connected by this node. For instance, if some area of water is polluted, tracing upstream analysis can be used to find where the contaminants may come from, and tracing downstream analysis can be used to trace the range polluted by the pollution source. Tracing data must have a flow direction.
Here we trace the upstream arcs of a node for Changchun data.
Set the tracing analysis parameters,including tracing type, the arc or node ID of query, the validation of uncertain flow direction, and so on.
Send a tracing analyst request to the server and recieve the returned analysis result.
Enjoy the result.
Client computing
SuperMap iClient for Leaflet provides Turf.js for client computing.
Turf is a JavaScript library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. Turf can be added to your website as a client-side plugin, or you can run Turf server-side with Node.js.
Turf uses GeoJSON for all geographic data. Turf expects the data to be standard WGS84 longitude, latitude coordinates. Check out geojson.io for a tool to easily create this data.
Most Turf functions work with GeoJSON features. These are pieces of data that represent a collection of properties (ie: population, elevation, zipcode, etc.) along with a geometry. GeoJSON has several geometry types such as:
- Point
- LineString
- Polygon
This example needs to import
Taking Turf grid analysis as an example
Enjoy the result.
Address match
SuperMap iClient for Leaflet supports for address match service. Address match service is the process of establishing a correspondence between a literal description address and its geographic location coordinates, which includes geocoding and geodecoding. That is, the user can find the address location by location name or the location at the specified location.
Geocoding
Geocoding returns the corresponding geographical coordinates and structured address details according to the location description, city range, and supports Chinese fuzzy matching.
Enjoy the result.
Geodecoding
Geodecoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name.
Enjoy the result.
Big data analysis
The SuperMap iClient for Leaflet is connected to the distributed analysis service of SuperMap iServer to provide users with big data analysis functions, including:
- Density analysis
- Point aggregation analysis
- Single object spatial query analysis
- Regional summary analysis
- Vector clip analysis
- Summary attributes analysis
- Topology validator analysis
Density analysis
Density analysis includes simple dot density analysis and kernel density anlysis.
- Simple dot density analysis is used to calculate the magnitude per unit area within the specified neighborhood shape for each point. The calculation method is that measured value of the point is divided by the specified neighborhood area. Where the neighborhood of the point is superimposed, the density values are also added. The density of each output raster is the sum of all neighborhood density values superimposed on the grid. The unit of the result raster value is the reciprocal of the square of the original data set unit is if the original dataset unit is meter, the unit of the result raster value is per square meter.
- Kernel density analysis is used to calculate the unit density of point and the line feature measurements over a specified neighborhood. It can intuitively reflect the distribution of discrete measurements in a continuous region. The result is a smooth surface with a large median value and a small peripheral value. The raster value is the unit density and falls to zero at the neighborhood boundary. Kernel density analysis can be used to calculate population density, building density, access to crime reports, population density monitoring in tourist areas, analysis of chain store operations, and more.
Here are the basic steps to implement a simple density analysis function, and the mesh type is quadrilateral.
Set the parameter kernelDensityJobParam, includes dataset, analysis method, analysis type, mesh size, etc.
Send a request to the server for density anlysis and get the returned result.
Enjoy the result.
Point aggregation analysis
Point aggregation analysis is a spatial analysis job for making aggregate graphs of point-to-point datasets. The map point features are divided by mesh region or polygons, and then the number of point features in each polygon object is calculated, and as the statistical value of the polygon object. The weight information of the points can also be introduced, and the weighted value of the points in the polygon object is used as the statistical value of the region object. Finally, based on the statistical value of the region object, according to the result of sorting the statistical value, color filling is performed on the opposite object based on ribbon.
Point aggregation analysis types include mesh aggregation and polygon aggregation. The mesh polygon aggregation graph can be divided into quadrilateral mesh and hexagon mesh according to mesh type.
Here are the basic steps to implement a point aggregation analysis function, and the aggregation type is quadrilateral.
Set the point aggregation analysis parameter summaryMeshJobParam, includes dataset, aggregation type, statistical mode, mesh size, etc.
Send a request to the server for point aggregation anlysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Single object spatial query analysis
Spatial query is a way to construct a filter condition by spatial positional relationship between geometric objects. For example, Spatial queries can be used to find spatial objects contained in polygons, separated or adjacent spatial objects, etc.
Single object spatial query analysis in distribute analysis service from SuperMap iServer refers to a single object in the query object dataset to do spatial query on the dataset being queried. If there are multiple objects in the query object dataset, the space query with the queryed dataset is done by default with the object with the smallest SmID.
This example needs to import
Here are the basic steps to implement a single object query analysis function, and the query mode is intersect.
Set the single object spatial query analysis parameters SingleObjectQueryJobsParam, includes dataset, query object dataset, query mode.
Send a request to the server for point aggregation anlysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Regional summary analysis
Regional summary analysis is a spatial analysis job that creates aggregated graphs for line datasets and polygon datasets. The map line or polygon feature is divided by a mesh surface or a polygon, and then each grid unit inner line or polygon feature is counted by a standard attribute field or a weight field, and the statistical result is used as a statistical value of the grid unit. Finally, the grid cells are sorted according to the size of the grid cells, and the grid cells are color-filled by the ribbon.
The concept of regional summary analysis is similar to the concept of point aggregation analysis. The difference is that point aggregation analysis is a statistical calculation of point datasets, while regional summary analysis is a statistical calculation of line datasets and polygon datasets. There are two statistical of grid unit statistics methods in regional summary analysis, includes statistics by standard attribute fields and statistics by weight field.
Here are the basic steps to implement a regional summary analysis function, and the summary type is mesh summary, the mesh type is quadrilateral.
Set the parameter summaryRegionJobParam, includes dataset, summary type, mesh type, etc.
Send a request to the server for regional summary anlysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Vector clip analysis
Vector clip includes inside clip and outside clip. For inside cliping, the portion of the clipped vector within the clipping region is retained in the result dataset. For outside cipping, the portion of the data that is not within the clipping region is preserved the result dataset.
For vector clip in distributed anlysis services, it is supported to clip the source dataset with one object from the clip dataset. If there are multiple objects in the clip datasets, by default, the object with the smallest SmID value will be used to clip the source dataset.
This example needs to import
Here are the steps to implement a vector clip analysis function, and the clip mode is inside clip.
Set the parameter vectorClipJobsParam, includes source dataset, clip dataset, clip analysis mode, etc.
Send a request to the server for vector clip analysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Summary attributes analysis
Summary attributes analysis refers to summarize the specified fields of the input dataset and calculate statistics on the specified attribute field. By setting the group field, attribute field and which kind of statistics, it can calculate the summary results.
Summary attributes analysis in distribute analysis service from SuperMap iServer will calculate the statistics on all the objects by default. You can also set multi-field with "," to separate each other and summarize attributes in each group fields. Supported statistic mode: max, min, average, sum, variance, stdDeviation.
Here are the basic steps to implement a summary attributes analysis function, and the statistic mode is sum.
Set the summary attributes analysis parameters summaryAttributesJobsParameter, includes summary attributes dataset , group field, attribute field and statistic modes.
Send a request to the server for summary attributes analysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Topology validator analysis
Topology validator analysis is used to check whether the given point, line or region data meets the specific topology rule, if not, it will return the objects that don't meet the rule.
Topology validator analysis in distribute analysis service from SuperMap iServer supports the following 7 topology rules: RegionNoOverlap, RegionNoOverlapWith, RegionCoveredByRegion, RegionContainedByRegion, LineNoOverlap, LineNoOverlapwith, PointNoIdentical.
Here are the basic steps to implement a topology validator analysis function, and the topology rule is RegionCoveredByRegion.
Set the topology validator analysis parameters topologyValidatorJobsParameter, includes topology validator dataset, topology rule and tolerance.
Send a request to the server for topology validator analysis and get the returned result. After the server successfully processes and returns the result, it is parsed.
Enjoy the result.
Data Flow
SuperMap iServer provides data flow service which realizes low latency and real-time data transfer between client and server. Data flow service uses WebSocket protocol to support full-duplex, two-way communication. The server can broadcast the result of real-time data analysis to the clients. Once the connection established between clients and data flow service, the clients can automatically receive broadcast data from the server.
Enjoy the result.
Data visualization
This guide will show you how to create data visualization with SuperMap iClient for Leaflet.
Heat map
A heat map is a two-dimensional representation of data in which values are represented by colors. A simple heat map provides an immediate visual summary of information. There are three items to draw a heat map with SuperMap iClient for Leaflet:
- Data. A heat map is created from point GIS data. Each data needs to have a geographical location and a weight value (can clearly represent the frequency of an event and the density of things distributed in a certain location, such as temperature, population density, etc.)
- Heat attenuation gradient fill color set. This set is used to render a gradient of each hot spot as it decays from the center outward
- Raduis. Each hotspot needs to be calculated for the attenuation from the center of the outer point according to the radius, and the color value that needs to be rendered for each pixel in the heat attenuation zone, then rendered in client.
Since the attenuation of the heat map is based on pixel, the visual effect is excellent, but it cannot be in one-to-one correspondence with the specific data. It can only indicate the difference between the weights, so it can be used for some precision requirements that are not high and need to be emphasized. In the gradual industry, for example, it is possible to make a weather effect comparison dynamic effect map, a seismic point intensity map, and the like.
You need to get leaflet-heat.js plugin to create heat maps. There are two ways to import leaflet-heat.js plugin:
1. Download leaflet-heat.js
Download leaflet-heat.js from GitHub.
Include the following code in the <head> of your HTML file.
2. Import via CDN
Example code.
Enjoy the result.
Animation
Leaflet provides the L.Icon.Pulse.js plugin for dynamic flash point effects. Support for Leaflet version 0.7.0 or later, compatible with modern browsers.
There are two ways to import L.Icon.Pulse.js plugin:
1. Download L.Icon.Pulse.js
Download L.Icon.Pulse.js from GitHub.
Include the JavaScript and CSS files in the <head> of your HTML file.
2. Import from
Example code.
Enjoy the result.
Aggregation
Leaflet.markercluster provides beautiful animated marker clustering functionality for Leaflet, a JS library for interactive maps.
There are two ways to import Leaflet.markercluster plugin:
1. Download Leaflet.markercluster
Download Leaflet.markercluster from GitHub.
Include the JavaScript and CSS files in the <head> of your HTML file.
2. Import from CDN
Example code.
Enjoy the result.
GraphicLayer
GraphicLayer mainly for point rendering of large data volumes on the web front-end. GraphicLayer supports the selection of object events.
This example needs to import
Create a graphicLayer and randomly draw 100,000 circles for visual display.
Enjoy the result.
ECharts
ECharts is an open source visualization library based on JavaScript. It runs smoothly on PCs and mobile devices. It is compatible with most browsers (IE8/9/10/11, Chrome, Firefox, Safari, etc.). Echarts relies on ZRender, a lightweight vector graphics library that provides intuitive, interactive rich, highly customizable data visualization charts.
ECharts provides general line charts, histograms, scatter plots, pie charts, K-line charts, box plots for statistics, maps for geographic data visualization, heat maps, line graphs, for relational data visualization. Diagrams, treemaps, sunbursts, parallel coordinates for multidimensional visualization, funnel plots for BI, dashboards, and support for mashups between graphs and graphs.
This example needs to import
SuperMap iClient for Leaflet supports for using Echarts visualization layer.
Taking the special effect map of Beijing bus route as an example, the data of the bus route is visualized:
Specify configuration items and data for the chart.
Enjoy the result.
MapV
Mapv is an open source geographic data visualization library that can be used to display a large amount of geographic data, point, line, and surface data. Each type of data also has different display types, such as direct dot, heat map, grid, and aggregation.
MapV can display a large number of point data, which can be in the form of heat map, grid, honeycomb, point aggregation, color interval, radius, and so on. MapV can display a large number of line data, such as ordinary line drawing, highlighting overlay, heat line data display, etc., as well as various animation effects, suitable for scenes with a large number of tracks. A large number of custom surface data can also be displayed, which is displayed by color interval. The administrative area is also one of the application scenarios and can be used directly.
This example needs to import
SuperMap iClient for Leaflet supports for using MapV visualization layer.
Taking the MapV strong boundary map as an example to visualize the data.
Specify configuration items and data for the chart.
Enjoy the result.
D3
D3 is a visual javascript library based on data manipulation html documents. D3 combines data with HTML, SVG, and CSS to create interactive data charts. D3 emphasizes Web standards, allowing you to leverage the power of modern browsers without the need for proprietary frameworks, combining powerful visualization components and data-driven methods into DOM operations.
For browser compatibility, D3 supports recent browsers such as Chrome, Edge, Firefox and Safari. D3 4.0 and below also supports IE9 and above. Some modules of D3 can work in older browsers.
This example needs to import
SuperMap iClient for Leaflet supports for using D3 visualization layer.
Enjoy the result.
OSM Buildings
OSM Buildings is a visual library for building and displaying 2.5D architectural effects on 2D maps.
OSM Buildings supports GeoJSON forma.
There are two ways to import OSMBuildings-Leaflet.js plugin.
1. Download OSMBuildings-Leaflet.js plugin
Download OSMBuildings-Leaflet.js plugin from GitHub.
Include the JavaScript file in the <head> of your HTML file.
2. Import via CDN
Core code.
Enjoy the result.