MySQL supports spatial extensions to enable the generation, storage, and analysis of geographic features. Additional information is available at http://dev.mysql.com/doc/refman/5.6/en/spatial-extensions.html
AspMap supports the Geometry data type. The MySqlLayer class can be used to access and edit such spatial data. A sample table in a MySQL database may look as the following:
NAME TYPE -------------------------------------- ID int(11) AUTO_INCREMENT GEOM geometry CITY_NAME varchar(40) STATE_NAME varchar(25) POPULATION decimal(9,0) SPATIAL KEY GEOM
The GEOM field stores shapes in the MySQL Geometry data format. The GEOM field has a spatial index (SPATIAL KEY GEOM) which is required to speed up spatial queries (for fast map rendering).
The ADO.NET framework does not have a built-in provider for MySQL. The MySQL Connector/Net provider (or any other MySQL provider) is required. The Connector/Net provider can be downloaded at http://dev.mysql.com/downloads/connector/net/
Create a MySqlLayer object and pass the connection string, table name and GEOM field to its constructor. It is also necessary to specify the FieldList property if you need attribute data for labeling or editing.
Add the MySqlLayer to the Map control using the AddLayer method:
Imports MySql.Data Imports AspMap Imports AspMap.Data
Dim connectionString As String = "Server=localhost;Database=DB;Uid=username;Pwd=password;"Dim tableName As String = "cities" Dim providerName As String = "MySql.Data.MySqlClient"
Dim mySqlLayer As MySqlLayer mySqlLayer = New MySqlLayer(providerName, connectionString, tableName, "GEOM") mySqlLayer.FieldList = "ID, CITY_NAME, POPULATION" Dim layer As Layer = map.AddLayer(mySqlLayer)
The MySqlLayer class supports editing of data as described in the Editing Spatial and Attribute Data topic.
© 2018 VDS Technologies
|Converted from CHM to HTML with chm2web Standard 2.85 (unicode)|