Introduction to ModestMap Technology

Source: Internet
Author: User

1. ModestMapsIntroduction:

ModestMaps is a set of class libraries developed based on As3.0 (ActionScript2.0 and ActionScript3.0) scripts and Python scripts. It complies with the BSD license agreement (see Unix knowledge) in Falsh, the map is displayed to interact with the user.

 

The purpose is to provide a lightweight, scalable, customizable, and free map display class library for beginners and developers, this class library helps developers interact with maps in their own projects. ModestMaps provides a core and robust element development kit with many hooks and additional functionality functions.

 

For example, see http://www.modestmaps.com/example.html (NASA Blue Marble satellite mages,) http://www.modestmaps.com/tutorial-actransit/actransit.html (AC Transit Oakland bus lines .)

There is a discussion group (discussion group: http://getsatisfaction.com/modestmaps) a sports car enthusiast (collect data) a newsletter dedicated to version updates and patches to help these make map tile providers continue to work for modestmaps. Of course, if you want to publish your own map tile service, you can also follow the instructions below to calculate the first map coordinate transformation and the second to create tile data. If you are interested in using modestmaps as a map server tool you can refer to ws-compose (an HTTP interface written using a Python script) development (http://www.modestmaps.com/examples-python-ws ).

 

Since December 2008, modest maps has not included support for Google maps. If you want to use googlemaps, you can use the Google's Maps API for Flash or the Google Static Maps API for development, these are similar to flash and Python.

 

Next let's take a look at what ModestMaps can do and cannot do.

 

First, ModestMaps can:

 

1. Display map based on map tiles, for example, from OpenstreetMap, from NASA Blue Marble, from Yahho !, Map Service Tiles from Microsoft or elsewhere.

2. Supports any geospatial projection settings for map tiles

3. Support roaming and Scaling

4. Supports tracking the location of geographic points of interest (geographical indication)

5. Supports the collaboration between the Code of ActionScript 2.0 and flashlite (this is not clear)

 

Second, ModestMaps cannot:

1. The display of default geographical tags is not provided

2. default buttons are not provided for scaling and translating maps

3. Other APIs are not provided to enable commercial area search and database search.

4. Enhanced flash components-UMap (http://www.afcomponents.com/components/umap_as3)

5. Geographic Data-Based BI tool spatialKey New Version released

II,ModestMapsTechnical implementation:

 

GoogleMapProvider inherits the AbstractMapProvider abstract class and implements the IMapProvider interface.

Code:

Package com. modestmaps. mapproviders. google

{

Import com. modestmaps. core. Coordinate;

Import com. modestmaps. mapproviders. AbstractMapProvider;

Import com. modestmaps. mapproviders. IMapProvider;

/**

*@

*@

**/

Public class GoogleMapProvider extends actmapprovider implements IMapProvider

{

// Private var tilePathBase: String = "http: // mt {0} .google.com/vt/lyrs?=1}&z=%2}&x=%3}&y=%4 }";

// Http://mt2.google.com/vt/lyrs=m@107&hl=lt&x=18&y=10&z=5&s=

Private var tilePathBase: String = "http: // {0} {1} region }";

Private const charStreet: String = "m ";

Private const charSatellite: String = "s ";

Private const charSatelliteHybrid: String = "y ";

Private const charPhysical: String = "t ";

Private const charPhysicalHybrid: String = "p ";

Private const charStreetOverlay: String = "h ";

Private const charStreetWaterOverlay: String = "r ";

Private const charServer: String = "mt ";

Private const secGoogleWord: String = "Galileo ";

Private var server_rr: int = 0;

Private var type: String;

// Google map zoom is between 0 and 17

Public function GoogleMapProvider (type: String = "STREET", minZoom: int = 0, maxZoom: int = 17)

{

Super (minZoom, maxZoom );

This. type = type;

_ TopLeftOutLimit. zoomTo (0 );

}

Protected function getZoomString (coord: Coordinate): String

{

Return "";

}

// Calc the zoom; must be update

Private function TileToZoom (tileLevel: int): int

{

Return tileLevel-8;

}

// Get google secwords

Private function GetSecGoogleWords (coord: Coordinate): Array

{

Var arr: Array = new Array ();

Var sec1: String = "";

Var sec2: String = "";

Var seclen: int = (coord. row * 3 + coord. column) % 8;

Sec2 = secGoogleWord. substr (0, seclen );

If (coord. column> = 1000 & coord. column <100000)

{

Sec1 = "& s = ";

}

Arr. push (sec1 );

Arr. push (sec2 );

Return arr;

}

// Http://mt2.google.com/vt/lyrs=m@107&hl=lt&x=18&y=10&z=5&s=

// "Http: // {0} {1} response }";

Private function xyzUrl (url: String, server: int, mapMode: String, zoom: int, tilePositionX: int, tilePositionY: int, sec1: String, sec2: String): String

{

Var x: int = tilePositionX;

Var y: int = tilePositionY;

 

Url = url. replace ("{0}", charServer );

Url = url. replace ("{1}", server. toString ());

Url = url. replace ("{2}", "vt ");

Url = url. replace ("{3}", "m @ 130 ");

Url = url. replace ("{4}", "en ");

Url = url. replace ("{5}", x. toString ());

Url = url. replace ("{6}", sec1 );

Url = url. replace ("{7}", y. toString ());

Url = url. replace ("{8}", zoom );

Url = url. replace ("{9}", sec2 );

// Url = "http://mt1.google.com/vt/lyrs=m@130&hl=en&src=api&x=6859&y=3347&zoom=4&s=Gali ";

Trace (url );

Return url;

}

Public function toString (): String

{

Return "GOOGLE" + this. type;

}

Public function getTileUrls (coord: Coordinate): Array

{

If (coord. row <0 | coord. row> = Math. pow (2, coord. zoom ))

{

Return null;

}

Trace (coord. toString ())

// Var zoom: int = TileToZoom (coord. zoom );

Server_rr = (coord. row + coord. column * 2) % 4;

Var arr: Array = GetSecGoogleWords (coord );

Var sec1: String = arr [0];

Var sec2: String = arr [1];

Var url: String = "";

Switch (this. type)

{

Case GoogleMapModes. Street:

Url = xyzUrl (this. tilePathBase, server_rr, charStreet, coord. zoom, coord. column, coord. row, sec1, sec2 );

Break;

Case GoogleMapModes. Physic:

Break;

Case GoogleMapModes. PhysicalHybrid:

Break;

Case GoogleMapModes. Satellite:

Break;

Case GoogleMapModes. SatelliteHybrid:

Break;

Case GoogleMapModes. StreetOverlay:

Break;

Case GoogleMapModes. StreetWaterOverly:

Break;

}

Var array: Array = new Array ();

Array. push (url );

Return array;

}

 

}

}

Use of the interface:

// Google map

VarProvide: GoogleMapProvider =NewGoogleMapProvider ();

VarExtend: MapExtent =NewMapExtent (40.764941, 40.693655,-73.938675,-74.039612 );

Map =NewMap (1000,1000,True, Provide, extend );

 

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.