Make your own electronic map flash Edition

Source: Internet
Author: User

Electronic maps can generally use Baidu APIs, which have powerful functions. However, they need to connect to official servers and are difficult to customize their own content.

 

1 select development language as3

 

2Map Projection

 

To seamlessly splice electronic map images, a projection must be used for the whole earth. Generally, mocato projection (Mercator projection),:

Under mocato projection, the ratio and area are obviously distorted (especially in areas near the poles ).

To simplify the computation, we use a spherical projection instead of an elliptical shape. Since projection is only used for Map Display, rather than numerical coordinates, we do not need the extra elliptical projection accuracy. The reason for using spherical projection is that about 0.33% of the scale is distorted in the Y axis, which is not visually obvious.

 

Ground Resolution and map scale

 

In addition to projection, rendering a map also requires a ground resolution or map scale. The lowest horizontal scaling level (level 1). The map is 512x512 pixels. Factor 2 for increasing map width and height at each Continuous scaling level: scale level 2 is 1024x1024 pixels, Level 3 is 2048x2048 pixels, level 4 is 4096x4096 pixels, and so on. Generally, the width and height (in pixels) of a map can be calculated as follows:

Map width = map Height = 256*2 horizontal pixels

Ground Resolution: the distance between the ground indicated by a pixel on the map. For example, at a resolution of 10 m/pixel on the ground, each pixel represents a distance of 10 m on the ground. The ground resolution depends on the scaling Level and Its latitude. The ground resolution (in meters/pixels) can be calculated as follows:

Ground Resolution = cos (latitude * PI/180) * Earth perimeter/map width

= (COS (latitude * PI/180) * 2 * pI * 6378137 meters)/(256*2 horizontal pixels)

Map scale: the ratio between map distance and ground distance in the same unit. For example, the map scale is, and every 1 inch on the map represents a 100000 inch distance from the ground. Similar to the ground resolution, the map scale depends on the latitude and the zoom level. It can be calculated by the ground resolution. For example, the screen resolution of each inch is usually 96 DPI:

Map scale = 1: ground resolution * screen DPI/0.0254 meters/inch

= 1 :( cos (latitude * PI/180) * 2 * pI * 6378137 * screen DPI)/(256*2*0.0254)

 

The following table lists each scaling level (measured at the equator ). (Note that the ground resolution and map scale also depend on the latitude, as shown in the preceding equation, but not in the following Table .)

 

Zoom level

Map width and height (in pixels)

Ground Resolution (meter/pixel)

Map scale (96 DPI)

1

512

78,271.5170

1: 295,829,355.45

2

1,024

39,135.7585

1: 147,914,677.73

3

2,048

19,567.8792

1: 73,957,338.86

4

4,096

9,783.9396

1: 36,978,669.43

5

8,192

4,891.9698

1: 18,489,334.72

6

16,384

2,445.9849

1: 9,244,667.36

7

32,768

1,222.9925

1: 4,622,333.68

8

65,536

611.4962

1: 2,311,166.84

9

131,072

305.7481

1: 1,155,583.42

10

262,144

152.8741

1: 577,791.71

11

524,288

76.4370

1: 288,895.85

12

1,048,576

38.2185

1: 144,447.93

13

2,097,152

19.1093

1: 72,223.96

14

4,194,304

9.5546

1: 36,111.98

15

8,388,608

4.7773

1: 18,055.99

16

16,777,216

2.3887

1: 9,028.00

17

33,554,432

1.1943

1: 4,514.00

18

67,108,864

0.5972

1: 2,257.00

19

134,217,728

0.2986

1: 1,128.50

20

268,435,456

0.1493

1: 564.25

21

536,870,912

0.0746

1: 282.12

22

1,073,741,824

0.0373

1: 141.06

23

2,147,483,648

0.0187

1: 70.53

 

Pixel coordinates

The details of each scaling level have the projection and scale. We can convert the geographical coordinates into pixel coordinates. Because the map width and height are at different scaling levels, the pixel coordinates are also the same. The pixel coordinates in the upper left corner of the map are always (0, 0 ). The pixel coordinates in the lower right corner of the map are (width-1 height-1), or the equation in the preceding section (256*2level-1, 256*2level-1 ). For example, in level 3, the pixel coordinate ranges from (0, 0) to (2047, 2047), as shown below:

 

With the longitude, latitude, and scaling levels, the pixel XY coordinates can be calculated as follows:

Sinlatitude = sin (latitude * PI/180)

Pixelx = (longpolling + 180)/360) * 256*2 level

Pixely = (0.5-log (1 + sinlatitude)/(1-sinlatitude)/(4 * PI) * 256*2 level

The latitude and longitude are in the WGS 84 Coordinate System. Although a map uses spherical projection, it is important to convert all geographic coordinates into a common coordinate system and convert them into the WGS 84 Coordinate System. Assume that the longitude ranges from-180 to 180 degrees, and the latitude range must be cropped from-85.05112878 to 85.05112878. This avoids an exception at the pole and makes the projection map a rectangle.

 

Tile coordinates and quadkeys

To optimize the search and display performance of a map, each tile is divided into 256x256 pixels. The number of pixels varies at each zoom level. The number of tiles is as follows:

Map width = map Height = 2 level tiles

The XY coordinate system of each tile ranges from the upper left corner (0, 0) to the lower right corner (2level-1, 2level-1 ). For example, the tile coordinates in level 3 range from (0, 0) to (7, 7) as follows:

 

Given a pair of pixel XY coordinates, you can easily determine the tiley coordinates:

Tilex = floor (pixelx/256)

Tiley = floor (pixely/256)

To optimize tiles indexing and storage, a string that combines two-dimensional tilexy coordinate systems into one dimension is called a quad-tree key, or "quadkeys" for short ". Each quadkey uniquely identifies a tile at each scaling level. Given a tilexy coordinate system (3, 5) with a zoom level of 3, The quadkey is determined as follows:

Tilex = 3 = 011 2

Tiley = 5 = 101 2

Quadkey = 100111 2 = 213 4 = "213"

 

 

3. Download map data

Test data can be downloaded from Google Maps.

 
4. The result is as follows:

5. The application displays the GPS coordinates.

Import the geographic coordinate data to the database and create a WebService. The query results are as follows:

 

 

 

6. Application, Topographic Map Division, and browsing.

 

 

Make your own electronic map flash Edition

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.