Jaa


Well Known Text Module

Note

Bing Maps Web Control SDK retirement

Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

Module Name: Microsoft.Maps.WellKnownText

Namespace: Microsoft.Maps.WellKnownText

Well Known Text (WKT) is an Open Geospatial Consortium (OGC) standard that is used to represent spatial data in a textual format. Most OGC-compliant systems support Well Known Text. Spatial functionality in SQL Server 2008, 2012, and SQL Azure can easily convert between a spatial object in the database and WKT. A WKT can only store the information for a single spatial object and this spatial data format is usually used as part of a larger file format or web service response. The following are examples of each of the geometry types represented as Well Known Text and the equivalent Bing Maps class that is generated when parsing a Well Known Text string.

Geometry Type Graphic Example Equivalent Bing Maps Class
Point Point POINT(-122.349 47.651) Pushpin
LineString LineString LINESTRING(-122.360 47.656, -122.343 47.656) Polyline
Polygon Polygon POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653)) Polygon
MultiPoint Multipoint MULTIPOINT(-122.360 47.656, -122.343 47.656) Pushpin[]
MultiLineString MultiLine String MULTILINESTRING ((-122.358 47.653, -122.348 47.649, -122.348 47.658), (-122.357 47.654, -122.357 47.657, -122.349 47.657, -122.349 47.650)) Polyline[]
MultiPolygon MultiPolygon MULTIPOLYGON(((-122.358 47.653, -122.348 47.649, -122.358 47.658, -122.358 47.653)), ((-122.341 47.656, -122.341 47.661, -122.351 47.661, -122.341 47.656))) Polygon[]
GeometryCollection GemoetryCollection GEOMETRYCOLLECTION ( POINT(-122.34900 47.65100), LINESTRING(-122.360 47.656, -122.343 47.656)) (Pushpin or Polyline or Polygon)[]

The coordinates in a WKT shape are ordered as “longitude latitude” which is important to remember as this is the opposite convention used by Bing Maps. The reasoning for this ordering is to be more consistent with geometric (X, Y) coordinate conventions. Since WKT is nothing more than a string with a defined format, they can be easily created and parsed.

The WellKnownText module only has one static class called WellKnownText that allows you to read and write Well Known Text data.

Static Methods

Name Return Value Description
read(wkt: string, styles?: StylesOptions) IPrimitive or IPrimitive[] Reads the data in well known text format and returns the shapes.
write(data: IPrimitive or IPrimitive[]) string Writes the data as a well known text.

Examples