├── .gitignore ├── index.js ├── images ├── V8Intellisense.gif ├── BingMapsLogoTeal.png ├── V8EventIntellisense.gif └── V8LoadModuleIntellisense.gif ├── types └── MicrosoftMaps │ ├── CustomMapStyles.d.ts │ ├── Microsoft.Maps.All.d.ts │ ├── Modules │ ├── WellKnownText.d.ts │ ├── Traffic.d.ts │ ├── GeoJSON.d.ts │ ├── Contour.d.ts │ ├── HeatMapLayer.d.ts │ ├── Autosuggest.d.ts │ ├── DataBinning.d.ts │ ├── Clustering.d.ts │ ├── Search.d.ts │ ├── DrawingTools.d.ts │ ├── GeoXml.d.ts │ ├── SpatialDataService.d.ts │ ├── SpatialMath.d.ts │ └── Directions.d.ts │ └── ConfigurationDrivenMaps.d.ts ├── .npmignore ├── package.json ├── CONTRIBUTING.md ├── LICENSE.md ├── SECURITY.md ├── Example.ts └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # npm log 2 | /npm-debug.log -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /// -------------------------------------------------------------------------------- /images/V8Intellisense.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Bing-Maps-V8-TypeScript-Definitions/HEAD/images/V8Intellisense.gif -------------------------------------------------------------------------------- /images/BingMapsLogoTeal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Bing-Maps-V8-TypeScript-Definitions/HEAD/images/BingMapsLogoTeal.png -------------------------------------------------------------------------------- /images/V8EventIntellisense.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Bing-Maps-V8-TypeScript-Definitions/HEAD/images/V8EventIntellisense.gif -------------------------------------------------------------------------------- /images/V8LoadModuleIntellisense.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Bing-Maps-V8-TypeScript-Definitions/HEAD/images/V8LoadModuleIntellisense.gif -------------------------------------------------------------------------------- /types/MicrosoftMaps/CustomMapStyles.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Bing-Maps-V8-TypeScript-Definitions/HEAD/types/MicrosoftMaps/CustomMapStyles.d.ts -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Ignore the git folder 2 | .git/ 3 | 4 | # Ignore the build folder which has the NuGet package spec. 5 | build/ 6 | 7 | # Ignore the images folder. 8 | images/ 9 | 10 | #ignore the unnecessary markdown pages 11 | CONTRIBUTING.md 12 | README.md 13 | 14 | # Ignore the examples files 15 | /Example.ts 16 | 17 | # npm log 18 | /npm-debug.log -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bingmaps", 3 | "version": "2.0.3", 4 | "description": "These are the official TypeScript definitions for the Bing Maps V8 SDK. These can be used to provide intellisense and rich error detection to your IDE.", 5 | "typings": "types/MicrosoftMaps/Microsoft.Maps.All.d.ts", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions.git" 9 | }, 10 | "keywords": [ 11 | "Microsoft", 12 | "Bing Maps", 13 | "Maps", 14 | "GIS", 15 | "TypeScript", 16 | "V8", 17 | "Web", 18 | "Map", 19 | "Geospatial", 20 | "JavaScript" 21 | ], 22 | "author": "Bing Maps (https://www.microsoft.com/maps/v8control.aspx)", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions/issues" 26 | }, 27 | "homepage": "https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions#readme", 28 | "main": "index.js", 29 | "scripts": { 30 | "test": "echo \"Error: no test specified\" && exit 1" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the Bing Maps V8 TypeScript Definitions # 2 | 3 | ## Code of Conduct ## 4 | 5 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 6 | 7 | ## How to contribute ## 8 | 9 | There are a couple of ways you can contribute to this repo: 10 | * **Ideas, feature requests and bugs**: We are open to all ideas and we want to get rid of bugs! Use the [Issues section](https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions/issues) to either report a new issue, provide your ideas or contribute to existing threads 11 | * **Documentation**: Found a typo or strangely worded sentences? Submit a PR! 12 | 13 | **Note:** If the issue you are experiencing is with the Bing Maps SDK itself, please report in the [MSDN forums](https://social.msdn.microsoft.com/Forums/en-US/home?forum=bingmapsajax&filter=alltypes&sort=lastpostdesc), or if you license Bing Maps, contact the [Bing Maps Enterprise support team](https://www.microsoft.com/maps/support.aspx). 14 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | 23 | -------------------------------------------------------------------------------- /types/MicrosoftMaps/Microsoft.Maps.All.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | /// 28 | 29 | /// 30 | /// 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | 44 | /// -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/WellKnownText.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | /** 29 | * Class responsible for readon/writing geo data in well known text format 30 | * @requires The Microsoft.Maps.WellKnownText module. 31 | */ 32 | export module WellKnownText { 33 | /** 34 | * Reads the data in wellknowntext format and returns the shapes. Multi-Geometry type shapes are returned as an array of shapes. 35 | * @param wkt The well known text string that needs to be parsed into shapes. 36 | * @param styles Styles to apply to the shapes. 37 | * @returns One of more shapes. 38 | */ 39 | export function read(wkt: string, styles?: IStylesOptions): IPrimitive | IPrimitive[]; 40 | 41 | /** 42 | * Writes the data into wellknowntext format. 43 | * @param data The data that needs to be serialized. 44 | * @returns Well known text formatted string. 45 | */ 46 | export function write(data: IPrimitive | IPrimitive[]): string; 47 | } 48 | } -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Traffic.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | /** 28 | * Adds a traffic incident and flow data to the map. 29 | * @requires The Microsoft.Maps.Traffic module. 30 | */ 31 | declare module Microsoft.Maps.Traffic { 32 | /** Options that can be customized in the Traffic manager. */ 33 | export interface ITrafficOptions { 34 | /** Displays the traffic flow layer. */ 35 | flowVisible?: boolean; 36 | 37 | /** Displays all traffic incidents. */ 38 | incidentsVisible?: boolean; 39 | 40 | /** Displays the traffic legend. */ 41 | legendVisible?: boolean; 42 | 43 | /** 44 | * Sets the opacity of the traffic flow tile layer. Must be a number between 0 and 1. The default is 1 unless the map 45 | * mode is set to lite, in which case the default is set to 0.7. 46 | */ 47 | opacity?: number; 48 | } 49 | 50 | /** 51 | * The TrafficManager class provides the ability to show traffic flow and incident data on top of the map. When creating an 52 | * instance of the TrafficManager class the map must be passed as an argument to the constructor. 53 | * @requires The Microsoft.Maps.Traffic module. 54 | */ 55 | export class TrafficManager { 56 | /** 57 | * @constructor 58 | * @requires The Microsoft.Maps.Traffic module. 59 | * @param map A map instnce to attach the traffic manager to. 60 | */ 61 | constructor(map: Map); 62 | 63 | /** Hides all traffic data. */ 64 | public hide(): void; 65 | 66 | /** Hides the traffic flow layer. */ 67 | public hideFlow(): void; 68 | 69 | /** Hides all traffic incidents. */ 70 | public hideIncidents(): void; 71 | 72 | /** Hides the traffic legend. */ 73 | public hideLegend(): void; 74 | 75 | /** 76 | * Sets the options for the traffic manager. 77 | * @param options The options for the traffic manager. 78 | */ 79 | public setOptions(options: ITrafficOptions): void; 80 | 81 | /** Displays all traffic data. */ 82 | public show(): void; 83 | 84 | /** Displays the traffic flow layer. */ 85 | public showFlow(): void; 86 | 87 | /** Displays all traffic incidents. */ 88 | public showIncidents(): void; 89 | 90 | /** Displays the traffic legend. */ 91 | public showLegend(): void; 92 | 93 | } 94 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/GeoJSON.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | 29 | /** GeoJSON object definition */ 30 | export interface IGeoJsonObject { 31 | /** 32 | * Type of the object 33 | * could be one of the following: 34 | * Point 35 | * LineString 36 | * Polygon 37 | * MultiPoint 38 | * MultiLineString 39 | * MultiPolygon 40 | * GeometryCollection 41 | * Feature 42 | * FeatureCollection 43 | */ 44 | type: string; 45 | 46 | /** Geometric coordinates of the object */ 47 | coordinates?: number[] | number[][] | number[][][] | number[][][][]; 48 | 49 | /** Additional properties of the object as a key,value pair */ 50 | properties?: any; 51 | 52 | /** Set of features (only applicable if the type is 'featurecollection') */ 53 | features?: IGeoJsonObject[]; 54 | 55 | /** Set of geometries (only applicable if the type is 'geometrycollection') */ 56 | geometries?: IGeoJsonObject[]; 57 | 58 | /** Geometry (only applicable if the type is 'feature') */ 59 | geometry?: IGeoJsonObject; 60 | 61 | /** identifier of a feature (only applicable if the type is 'feature') */ 62 | id?: any; 63 | } 64 | 65 | /** 66 | * Class responsible for reading/writing geo data in GeoJson format 67 | * @requires The Microsoft.Maps.GeoJson module. 68 | */ 69 | export module GeoJson { 70 | /** 71 | * Reads the data from a given url and returns the shapes. 72 | * @param url GeoJson download url. 73 | * @param callback Callback function that needs to be called once the data is downloaded and parsed. 74 | * @param jsonpQueryParam The name of the url query param to make a jsonp request. 75 | * @param styles Styles that needs to be applied. 76 | */ 77 | export function readFromUrl(url: string, callback: (data: IPrimitive | IPrimitive[]) => void, jsonpQueryParam?: string, styles?: IStylesOptions): void; 78 | 79 | /** 80 | * Reads the data in geoJson format and returns the shapes. 81 | * @param geoJson GeoJson data object that needs to be parsed into shapes. 82 | * @param styles Styles that needs to be applied. 83 | * @returns An array of shapes. 84 | */ 85 | export function read(geoJson: IGeoJsonObject | string, styles?: IStylesOptions): IPrimitive | IPrimitive[]; 86 | 87 | /** 88 | * Writes the data into geoJson format. 89 | * @param data Data that needs to be serialized. 90 | * @returns A geoJson formatted string. 91 | */ 92 | export function write(data: IPrimitive | IPrimitive[]): IGeoJsonObject; 93 | } 94 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Contour.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | 29 | /** 30 | * The contour layer options 31 | */ 32 | interface IContourLayerOptions { 33 | /** The z-index of this layer */ 34 | zIndex?: number; 35 | 36 | /** Whether the layer is visible */ 37 | visible?: boolean; 38 | 39 | /** A callback function which defines the color of the contour line fill. */ 40 | colorCallback?: (contourValue: number | string) => string | Color; 41 | 42 | /** The polygon options that apply to all contour lines of this layer */ 43 | polygonOptions?: IPolygonOptions; 44 | } 45 | 46 | /** 47 | * The contour line of a contour layer 48 | */ 49 | export class ContourLine extends Polygon { 50 | /** The contour lines that are directly nested inside this contour line */ 51 | public innerContourLines: ContourLine[]; 52 | 53 | /** The outer/parent contour line of this contour */ 54 | public outerContourLine: ContourLine; 55 | 56 | /** The data value associated with this contour line */ 57 | public contourValue: number | string; 58 | 59 | /** 60 | * @constructor 61 | * @param boundary The boundary of this contour line 62 | * @param contourValue The value associated with this contour line 63 | */ 64 | constructor(boundary: Location[], contourValue?: number | string); 65 | } 66 | 67 | /** 68 | * The contour layer class. 69 | */ 70 | export class ContourLayer extends Layer { 71 | /** 72 | * @constructor 73 | * @param contourLines The contour lines that compose this layer. 74 | * @param options The contour layer options. 75 | */ 76 | constructor(contourLines: ContourLine[], options?: IContourLayerOptions); 77 | 78 | /** 79 | * Clears all data on the contour layer. 80 | */ 81 | public clear(): void; 82 | 83 | /** 84 | * Gets the contour lines of this layer. 85 | * @returns The contour lines of this layer. 86 | */ 87 | public getContourLines(): ContourLine[]; 88 | 89 | /** 90 | * Gets the polygons that were generated from the contour lines in this layer. 91 | * @returns The polygons that were generated from the contour lines in this layer. 92 | */ 93 | public getContourPolygons(): Polygon[]; 94 | 95 | /** 96 | * Retrieves the options of this contour layer. 97 | * @returns The options of this contour layer. 98 | */ 99 | public getOptions(): IContourLayerOptions; 100 | 101 | /** 102 | * Sets the contour lines used to calculate the polygon areas of this layer. 103 | * @param contourLines The contour lines used to calculate the polygon areas of this layer. 104 | */ 105 | public setContourLines(contourLines: ContourLine[]): void; 106 | 107 | /** 108 | * Sets the options of the contour layer. 109 | * @param options The new options to update the layer. 110 | */ 111 | public setOptions(options: IContourLayerOptions): void; 112 | } 113 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/ConfigurationDrivenMaps.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | /// 27 | /// 28 | 29 | declare module Microsoft.Maps { 30 | 31 | ////////////////////////////////////////////// 32 | /// Interfaces 33 | ////////////////////////////////////////////// 34 | 35 | /** GeoJson options to use when loading a GeoJson file. */ 36 | export interface IGeoJsonReadOptions { 37 | /** 38 | * If the GeoJSON file is hosted on a different domain, and CORS is not enabled, but does support JSONP, 39 | * you will need to specify the name of JSONP URL parameter that can be used to download the file across different domains. 40 | */ 41 | jsonpQueryParam?: string, 42 | 43 | /** An optional name to identify the layer by. */ 44 | layerName?: string, 45 | 46 | /** The styles to apply to shapes that don't have a defined style in the XML. */ 47 | style?: IStylesOptions 48 | } 49 | 50 | /** Steps to execute after a module is loaded. */ 51 | export interface PostModuleAction { 52 | /** A URL to load the data layer from. Currently supports data in GeoJSON, GeoRSS (with inline GML), GPX, KML, and KMZ formats. */ 53 | addLayerFromUrl: string, 54 | 55 | /** Options to use when loading data via the GeoXml module. */ 56 | geoXmlOption?: IGeoXmlLayerOptions, 57 | 58 | /** Options to use when loading data via the GeoJson module. */ 59 | geoJsonOption?: IGeoJsonReadOptions 60 | } 61 | 62 | /** Defines which module should be loaded, and the data sets that should be loaded with it. Currently supports the "Microsoft.Maps.GeoXml" and "Microsoft.Maps.GeoJson" modules.*/ 63 | export interface IConfigurableMapModule { 64 | /** Name of the module to load. Supported values: "Microsoft.Maps.GeoXml", "Microsoft.Maps.GeoJson". */ 65 | moduleName: string, 66 | 67 | /** A set of steps to execute after a module is loaded. */ 68 | moduleOptions: PostModuleAction | PostModuleAction[] 69 | } 70 | 71 | /** 72 | * Configurable map definitionm includes initial options to load the map as well as a list of modules to load afterwards. 73 | */ 74 | export interface IConfigurableMapOptions { 75 | /** Initial map options. */ 76 | mapOptions: IMapOptions, 77 | 78 | /** List of configuration modules to load. */ 79 | modules: IConfigurableMapModule[] 80 | } 81 | 82 | ////////////////////////////////////////////// 83 | /// Classes 84 | ////////////////////////////////////////////// 85 | 86 | /** 87 | * The configuration driven map framework. 88 | */ 89 | export class ConfigurableMap { 90 | 91 | /** 92 | * A static function that loads a map using a JSON configuraiton file. 93 | * @param element The parent element of the map as a CSS selector string or HTMLElement. 94 | * @param configFileUrl The Url to download the JSON configuration file from. This should JSON file should contain a IConfigurableMapOptions object. 95 | * @param withCredentials Creates the config file request with the setwithcredentials property. 96 | * @param requestHeaders Set of headers that need to be added to config file request. 97 | * @param callback Callback that is triggered when the map loads successfully. 98 | * @param errorCallback Callback that is triggered when an error occurs when loading the map. 99 | */ 100 | public static createFromConfig(element: string | HTMLElement, configFileUrl: string, withCredentials: boolean, requestHeaders?: IDictionary, callback?: (map: Map) => void, errorCallback?: (errorMsg: string) => void): void; 101 | } 102 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/HeatMapLayer.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | /** Options for customizing how the heat map is rendered. */ 29 | export interface IHeatMapLayerOptions { 30 | /** 31 | * The temperature gradient that is used to colorize the map. Default gradient: 32 | * { 33 | * '0.00': 'rgb(255,0,255)', // Magenta 34 | * '0.25': 'rgb(0,0,255)', // Blue 35 | * '0.50': 'rgb(0,255,0)', // Green 36 | * '0.75': 'rgb(255,255,0)', // Yellow 37 | * '1.00': 'rgb(255,0,0)' // Red 38 | * } 39 | */ 40 | colorGradient?: IDictionary; 41 | 42 | /** 43 | * The intensity of each heat point. This is a decimal value between 0 and 1. This is used to specify how "hot" a single data point should be. Default: 0.5 44 | */ 45 | intensity?: number; 46 | 47 | /** 48 | * The opacity of the HeatMapLayer canvas. Value should be a decimal between 0 and 1. Default: 1 49 | */ 50 | opacity?: number; 51 | 52 | /** 53 | * The radius to draw each data point on the map. Default: 10 54 | */ 55 | radius?: number; 56 | 57 | /** 58 | * The distance units of the radius. Possible values are: 59 | * 60 | * • 'pixels' (defualt) 61 | * • 'meters' 62 | * 63 | * When set to pixels the size of each data point will always be the same radius, regardless of zoom level. When set to meters, the size of the data points 64 | * will scale based on zoom level so as to ensure that the radius is spatially accurate. 65 | */ 66 | unit?: 'meters' | 'pixel'; 67 | 68 | /** A boolean indicating if the heat map layer is visible or not. **/ 69 | visible?: boolean; 70 | } 71 | 72 | /** 73 | * Class for rendering data as a heat map layer. 74 | * @requires The Microsoft.Maps.Heatmap module. 75 | */ 76 | export class HeatMapLayer implements IDataLayer { 77 | /** 78 | * @constructor 79 | * @requires The Microsoft.Maps.Heatmap module. 80 | * @param locations Set of locations to visualize as a heat map. 81 | * @param options Options for customizing how the heat map is rendered. 82 | */ 83 | constructor(locations: (Location | Pushpin)[], options?: IHeatMapLayerOptions); 84 | 85 | /** Clears all data in the heat map layer. */ 86 | public clear(): void; 87 | 88 | /** Disposes the heat map layer. */ 89 | public dispose(): void; 90 | 91 | /** 92 | * Gets a boolean indicating if the heat map layer is visible or not. 93 | * @returns A boolean indicating if the heat map layer is visible or not. 94 | */ 95 | public getVisible(): boolean; 96 | 97 | /** 98 | * @deprecated 99 | * Hides the heat map layer. 100 | */ 101 | public hide(): void; 102 | 103 | /** 104 | * Specifies the locations to use when generating the heat map. 105 | * @param locations Set of locations. 106 | */ 107 | public setLocations(locations: (Location | Pushpin)[]): void; 108 | 109 | /** 110 | * Sets the options to use with the heat map layer. 111 | * @param options Set of heat map layer options. 112 | */ 113 | public setOptions(options: IHeatMapLayerOptions): void; 114 | 115 | /** 116 | * Sets the visibility of the heat map layer. 117 | * @param visible A boolean indicating if the heat map layer is visible or not. 118 | */ 119 | public setVisible(visible: boolean): void; 120 | 121 | /** 122 | * @deprecated 123 | * Shows the heat map layer. 124 | */ 125 | public show(): void; 126 | } 127 | } -------------------------------------------------------------------------------- /Example.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var map = new Microsoft.Maps.Map('#MyMap', { 4 | credentials: 'Your Bing Maps Key' 5 | }); 6 | 7 | var pushpins = Microsoft.Maps.TestDataGenerator.getPushpins(10, this.map.getBounds()); 8 | var infobox = new Microsoft.Maps.Infobox(pushpins[0].getLocation(), { visible: false }); 9 | infobox.setMap(map); 10 | for (var i = 0; i < pushpins.length; i++) { } 11 | 12 | 13 | Microsoft.Maps.Events.addHandler(map, 'click', (e: Microsoft.Maps.IMouseEventArgs) => { 14 | //The location on the map that the user clicked. 15 | var loc = e.location; 16 | }); 17 | 18 | var layer = new Microsoft.Maps.Layer(); 19 | 20 | var pin = new Microsoft.Maps.Pushpin(map.getCenter(), { 21 | color: new Microsoft.Maps.Color(150, 150, 0, 0) 22 | }); 23 | 24 | Microsoft.Maps.Events.addOne(pin, 'changed', (e: Microsoft.Maps.IPrimitiveChangedEventArgs) => { 25 | //e.name => name of property that changed. 26 | //e.sender => reference to the pushpin object that changed. 27 | }); 28 | 29 | layer.add(pin); 30 | 31 | map.layers.insert(layer); 32 | 33 | Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', () => { 34 | Microsoft.Maps.GeoJson.readFromUrl('URL to file', (data) => { 35 | if (data instanceof Array) { 36 | //Data is an array of shapes. 37 | } else { 38 | //Data is a single shape. 39 | } 40 | 41 | map.entities.push(data); 42 | }); 43 | }); 44 | 45 | Microsoft.Maps.loadModule('Microsoft.Maps.Autosuggest', { 46 | credentials: 'Your Bing Maps Key', 47 | callback: () => { 48 | var asManager = new Microsoft.Maps.AutosuggestManager(); 49 | asManager.attachAutosuggest('mySuggestionTextbox', 'suggestionsContainer', (result) => { 50 | //Do something with the selected result. 51 | }); 52 | } 53 | }); 54 | 55 | Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', { 56 | credentials: 'Your Bing Maps Key', 57 | callback: () => { 58 | var drawingTools = new Microsoft.Maps.DrawingTools(map); 59 | drawingTools.create(Microsoft.Maps.DrawingTools.ShapeType.polyline); 60 | } 61 | }); 62 | 63 | Microsoft.Maps.loadModule('Microsoft.Maps.Search', () => { 64 | var searchManager = new Microsoft.Maps.Search.SearchManager(map); 65 | searchManager.geocode({ 66 | bounds: map.getBounds(), 67 | where: 'somewhere', 68 | callback: (answer, userData) => { 69 | map.setView({ bounds: answer.results[0].bestView }); 70 | map.entities.push(new Microsoft.Maps.Pushpin(answer.results[0].location)); 71 | } 72 | }); 73 | }); 74 | 75 | Microsoft.Maps.loadModule('Microsoft.Maps.Directions', () => { 76 | var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map); 77 | directionsManager.addWaypoint(new Microsoft.Maps.Directions.Waypoint({ 78 | address: 'Redmond, WA' 79 | })); 80 | 81 | directionsManager.addWaypoint(new Microsoft.Maps.Directions.Waypoint({ 82 | address: 'Seatle, WA' 83 | })); 84 | 85 | Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', (args) => { 86 | 87 | }); 88 | directionsManager.calculateDirections(); 89 | }); 90 | 91 | Microsoft.Maps.loadModule('Microsoft.Maps.DataBinning', () => { 92 | var dataBinLayer = new Microsoft.Maps.DataBinningLayer(); 93 | dataBinLayer.setPushpins(Microsoft.Maps.TestDataGenerator.getPushpins(100)); 94 | dataBinLayer.setOptions({ 95 | scaleCallback: (info, min, max) => { 96 | return info.metrics.count / max.count; 97 | } 98 | }); 99 | map.layers.insert(dataBinLayer); 100 | }); 101 | 102 | 103 | Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', () => { 104 | var kml = Microsoft.Maps.GeoXml.write(pin, { 105 | indentChars: '\t', 106 | newLineChars: '\n', 107 | prettyPrint: true, 108 | roundLocations: true, 109 | validate: true, 110 | xmlFormat: Microsoft.Maps.GeoXmlFormat.Kml 111 | }); 112 | }); 113 | 114 | /*********************** 115 | * Custom Overlay Example 116 | ************************/ 117 | 118 | class TopographicOverlay extends Microsoft.Maps.CustomOverlay { 119 | 120 | bounds: Microsoft.Maps.LocationRect; 121 | image: string; 122 | 123 | private img: HTMLImageElement; 124 | 125 | constructor(bounds: Microsoft.Maps.LocationRect, image: string) { 126 | super({ beneathLabels: true }); 127 | 128 | this.bounds = bounds; 129 | this.image = image; 130 | } 131 | 132 | onAdd() { 133 | //Create an image element that will be used as the overlay. 134 | this.img = document.createElement('img'); 135 | this.img.src = this.image; 136 | this.img.style.width = '100%'; 137 | this.img.style.height = '100%'; 138 | this.img.style.position = 'absolute'; 139 | this.setHtmlElement(this.img); 140 | } 141 | 142 | onLoad() { 143 | this.repositionOverlay(); 144 | 145 | //Update the position of the image when the view changes. 146 | Microsoft.Maps.Events.addHandler(map, 'viewchange', function () { 147 | this.repositionOverlay(); 148 | }); 149 | } 150 | 151 | onRemove() { 152 | //Logic to perform when overlay has been removed from the map. 153 | } 154 | 155 | private repositionOverlay() { 156 | //Streach and position the image based on the bounding box pixel coordinates. 157 | var topLeft = map.tryLocationToPixel(this.bounds.getNorthwest(), Microsoft.Maps.PixelReference.control); 158 | var bottomRight = map.tryLocationToPixel(this.bounds.getSoutheast(), Microsoft.Maps.PixelReference.control); 159 | 160 | this.img.style.left = topLeft.x + 'px'; 161 | this.img.style.top = topLeft.y + 'px'; 162 | this.img.style.width = (bottomRight.x - topLeft.x) + 'px'; 163 | this.img.style.width = (bottomRight.x - topLeft.x) + 'px'; 164 | this.img.style.height = (bottomRight.y - topLeft.y) + 'px'; 165 | } 166 | } 167 | 168 | //The bounding box and url for the image to overlay. 169 | var bounds = Microsoft.Maps.LocationRect.fromCorners(new Microsoft.Maps.Location(40.5, -123.5), new Microsoft.Maps.Location(40, -123)); 170 | var imageSrc = 'https://bingmapsisdk.blob.core.windows.net/isdksamples/topographicMap.gif'; 171 | 172 | //Implement the new custom overlay class. 173 | var overlay = new TopographicOverlay(bounds, imageSrc); 174 | 175 | //Add the custom overlay to the map. 176 | map.layers.insert(overlay); 177 | -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Autosuggest.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | /** Options used to customize the autosuggest functionality. */ 29 | export interface IAutosuggestOptions { 30 | /** Specifies if street address suggestions should be returned. Default: true */ 31 | addressSuggestions?: boolean; 32 | 33 | /** 34 | * Specifies if the user’s location should be auto detected using their IP address, if no location information is provided 35 | * in the userLocation property. Default: true 36 | */ 37 | autoDetectLocation?: boolean; 38 | 39 | /** 40 | * A bounding box that is used to help influence the results such that locations that are in or near this bounding box 41 | * are given more weight than they would normally. 42 | */ 43 | bounds?: LocationRect; 44 | 45 | /** 46 | * A string specifying the ISO 3166-1 alpha-2 country region code which is used to limit suggests to a single country. 47 | * https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 48 | */ 49 | countryCode?: string; 50 | 51 | /** 52 | * A reference to a map instance. If the useMapView property is set to true, the bounding box of the map view will be used 53 | * to influence the weight of suggestions. 54 | */ 55 | map?: Map; 56 | 57 | /** The maximum number of results to return. Can be any value between 1 and 10. Default: 5 */ 58 | maxResults?: number; 59 | 60 | /** Specifies if place suggestions (city, landmark, etc.) should be returned. Default: true */ 61 | placeSuggestions?: boolean; 62 | 63 | /** 64 | * Indicates if the maps bounding box should be used to influence the suggested results. Ignored if the bounds property is 65 | * set. Default: true 66 | */ 67 | useMapView?: boolean; 68 | 69 | /** A coordinate indicating where the user is located. This will influence the results to be more relevant to the user. */ 70 | userLocation?: Location; 71 | } 72 | 73 | /** Represents the suggestion result from the Autosuggest manager. */ 74 | export interface ISuggestionResult { 75 | /** A structured address object for the result. */ 76 | address: IAddress; 77 | 78 | /** A LocationRect that can be used to set the map view over the result. */ 79 | bestView: LocationRect; 80 | 81 | /** Unique entity id to be used for searching the entity. */ 82 | entityId: string; 83 | 84 | /** The type of the result; Address, Place */ 85 | entityType: string; 86 | 87 | /** The sub type of result; Address, RoadBlock, PopulatedPlace, CountryRegion, etc. */ 88 | entitySubType: string; 89 | 90 | /** A nicely formatted suggestion string for the result based on market. */ 91 | formattedSuggestion: string; 92 | 93 | /** 94 | * The coordinate of the result. This value is only returned for place (city, landmarks) results and not for addresses. 95 | * Street addresses will need to be geocoded to get their location. 96 | */ 97 | location: Location; 98 | 99 | /** A secondary title that provides additional context to the title value of the suggestion. **/ 100 | subtitle: string; 101 | 102 | /** The display title for the result (i.e. “Redmond”). */ 103 | title: string; 104 | } 105 | 106 | /** 107 | * The AutosuggestManager is the primary class in the Autosuggest module that powers the autosuggest functionality. 108 | * @requires The Microsoft.Maps.Autosuggest module. 109 | */ 110 | export class AutosuggestManager { 111 | /** 112 | * @constructor 113 | * @requires The Microsoft.Maps.Autosuggest module. 114 | * @param options The options to use with the autosuggest manager. 115 | */ 116 | constructor(options?: IAutosuggestOptions); 117 | 118 | /** 119 | * Attaches the Autosuggest functionality to an input box. 120 | * @param suggestionBoxId The HTML element identifier of the input box. 121 | * @param suggestionContainerId The Id of container where suggestions will be displayed. 122 | * @param selectedSuggestionCallback A reference to a callback function that will be called when a user selects a suggestion from the Autosuggest UI. 123 | */ 124 | public attachAutosuggest(suggestionBoxId: string, suggestionContainerId: string, selectedSuggestionCallback: (result: ISuggestionResult) => void) : void; 125 | 126 | /** Detaches the autosuggest functionality from the input box, freeing any resources it has or events it has tied to. */ 127 | public detachAutosuggest(): void; 128 | 129 | /** Disposes the Autosuggest object, freeing any resources it has or events it has tied to. */ 130 | public dispose(): void; 131 | 132 | /** 133 | * Gets the options currently used by the autosuggest manager. 134 | * @returns The options currently used by the autosuggest manager. 135 | */ 136 | public getOptions(): IAutosuggestOptions; 137 | 138 | /** 139 | * Programmatically retrieves suggestions for queries without the need to attach a textbox to the AutosuggestManager. 140 | * @param query The text to get suggestions for. 141 | * @param callback The callback function to return the suggestions to. 142 | */ 143 | public getSuggestions(query: string, callback: (suggestions: ISuggestionResult[], query: string) => void): void; 144 | 145 | /** 146 | * Sets the options currently used by the autosuggest manager. 147 | * @param options The options to use with the autosuggest manager. 148 | */ 149 | public setOptions(options?: IAutosuggestOptions): void; 150 | } 151 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/DataBinning.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | /// 27 | 28 | declare module Microsoft.Maps { 29 | 30 | /** 31 | * Specifies the shape of data bin rendered in the layer. 32 | */ 33 | export enum DataBinType { 34 | /* Renders data bins as circles in a square grid. */ 35 | circle, 36 | 37 | /* Renders data bins as hexagons with a flat top edge. */ 38 | hexagon, 39 | 40 | /* Renders data bins as circles in a hexagonal grid. */ 41 | hexCircle, 42 | 43 | /* Renders data bins as hexagons with a pointy top corner. */ 44 | pointyHexagon, 45 | 46 | /* Renders data bins as a square grid. */ 47 | square 48 | } 49 | 50 | /** 51 | * A set options the define how a data binning layer is rendered. 52 | */ 53 | export interface IDataBinningOptions { 54 | /* The name of a property in the Pushpin.metadata object on which to perform calculations (average, count, sum) against the pushpins in each data bin. */ 55 | aggregationProperty?: string; 56 | 57 | /* 58 | * A callback function which defines the color a data bin polygon should be. This callback recieves data bin information 59 | * along with the min and max calculated metrics for the data set. If set, this callback function must return a color value. 60 | */ 61 | colorCallback?: (binInfo: IDataBinInfo, min: IDataBinMetrics, max: IDataBinMetrics) => string | Color; 62 | 63 | /* The shape of the data bin to generate. Default: hexagon */ 64 | dataBinType?: DataBinType; 65 | 66 | /* The distance units of the radius option. Default: meters */ 67 | distanceUnits?: SpatialMath.DistanceUnits; 68 | 69 | /* The default options used for rendering the data bin polygons. */ 70 | polygonOptions?: IPolygonOptions; 71 | 72 | /* 73 | * A spatial distance which will be converted into a pixel distance at the equater and used to generate symetrically sized data bins 74 | * that have the apprimate spatial distance radius. Default: 1000 75 | */ 76 | radius?: number; 77 | 78 | /* 79 | * A callback function which defines how much to scale a data bins size. This callback recieves data bin information 80 | * along with the min and max calculated metrics for the data set. If set, this callback function must return a number between 0 and 1. 81 | */ 82 | scaleCallback?: (binInfo: IDataBinInfo, min: IDataBinMetrics, max: IDataBinMetrics) => number; 83 | } 84 | 85 | /** 86 | * A set of values calculated from the pushpins in a data bin. 87 | */ 88 | export interface IDataBinMetrics { 89 | 90 | /* The average value of the aggregation property of the pushpins in a data bin. */ 91 | average?: number; 92 | 93 | /* The number of pushpins in a data bin. */ 94 | count?: number; 95 | 96 | /* The number of pushpins in the data bin who's aggregation property has a value. */ 97 | countNotBlank?: number; 98 | 99 | /* The number of pushpins in the data bin who's aggregation property is a valid number. */ 100 | countNumbers?: number; 101 | 102 | /* The sum of the aggregation property of the pushpins in a data bin. */ 103 | sum?: number; 104 | } 105 | 106 | /** 107 | * The result of a calculated data bin. 108 | */ 109 | export interface IDataBinInfo { 110 | /* An array of all the pushpins that are in the data bin. */ 111 | containedPushpins: Microsoft.Maps.Pushpin[]; 112 | 113 | /* A set of calculated metric values determined using the aggregationProperty value of all the pushpins contained in the data bin. */ 114 | metrics: IDataBinMetrics; 115 | } 116 | 117 | /** 118 | * A polygon which represents a data bin on the map and contains the data bin information. 119 | */ 120 | 121 | export class DataBinPolygon extends Polygon { 122 | /* Information about the data bin; the contained pushpins and calculated metrics. */ 123 | public dataBinInfo: IDataBinInfo; 124 | } 125 | 126 | /** 127 | * This class provides a data binning visualization for the map. It takes in an array of pushpins, groups them into 128 | * symmetrical shapes that fit together in a grid such as hexagons. Aggregation of data values are done and can be 129 | * used to customize how the data bins are rendered on the map (i.e. scale / color) . 130 | */ 131 | export class DataBinningLayer extends Layer { 132 | /** 133 | * Initializes the data binning layer. 134 | * @param pushpins The array of pushpins that are used to generate the data bins. 135 | * @param options The options used for calculating and rendering the data bins. 136 | */ 137 | constructor(pushpins?: Pushpin[], options?: IDataBinningOptions); 138 | 139 | /** 140 | * Gets the options used for calculating and rendering the data bins. 141 | * @returns The options used for calculating and rendering the data bins. 142 | */ 143 | public getOptions(): IDataBinningOptions; 144 | 145 | /** 146 | * Gets all pushpins that are in the layers. 147 | * @returns All pushpins that are in the layers. 148 | */ 149 | public getPushpins(): Pushpin[]; 150 | 151 | /** 152 | * Sets the array of pushpins that are used to generate the data bins. 153 | * @param pushpins The array of pushpins that are used to generate the data bins. 154 | */ 155 | public setPushpins(pushpins: Pushpin[]): void; 156 | 157 | /** 158 | * Clears all the data in the data binning layer. 159 | */ 160 | public clear(): void; 161 | 162 | /** 163 | * Cleans up any resources this object is consuming. 164 | */ 165 | public dispose(): void; 166 | 167 | /** 168 | * Sets the options used for calculating and rendering the data bins. 169 | * @param options The options used for calculating and rendering the data bins. 170 | */ 171 | public setOptions(options: IDataBinningOptions): void; 172 | } 173 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Clustering.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | /** The options used to customize how the ClusterLayer functions. */ 29 | export interface IClusterLayerOptions { 30 | /** 31 | * A callback function that is fired after the clustering for a map view has completed. This is useful if you want to generate a list of locations based on what is in the current view. 32 | */ 33 | callback?: () => void; 34 | 35 | /** 36 | * A callback function that allows you to process a clustered pushpin before it is added to a layer. This is useful if you want to add events or set style options on the clustered pushpin. 37 | */ 38 | clusteredPinCallback?: (pin: ClusterPushpin) => void; 39 | 40 | /** 41 | * Indicates if the layer should cluster the locations or not. Default: true 42 | */ 43 | clusteringEnabled?: boolean; 44 | 45 | /** 46 | * Defines how clusters are positioned on the map. Default: MeanAverage 47 | */ 48 | clusterPlacementType?: ClusterPlacementType; 49 | 50 | /** 51 | * The width and height of the gird cells used for clustering in pixels. Default: 45 52 | */ 53 | gridSize?: number; 54 | 55 | /** 56 | * Offsets the placement of clustered pushpins by a set number of pixels. This option is only available when the placement type is set to GridCenter. 57 | * This is useful if you have multiple cluster layers on the map and you want to offset the clustered pushpins between the layers so that they are visible, 58 | * otherwise the clusters from the different layers would overlap completely. 59 | */ 60 | layerOffset?: Point; 61 | 62 | /** 63 | * A boolean indicating if the layer is visible or not. 64 | */ 65 | visible?: boolean; 66 | 67 | /** 68 | * The z-index of the layer. 69 | */ 70 | zIndex?: number; 71 | } 72 | 73 | /** 74 | * Used to specify how a clustered pushpin should be positioned relative to the pushpins it contains. 75 | * @requires The Microsoft.Maps.Clustering module. 76 | */ 77 | export enum ClusterPlacementType { 78 | /** 79 | * Mean Average placement calculates the average position of a group of coordinates. This method creates a more realistic representation of the data, 80 | * however requires more processing power and increases the chances of pushpins overlapping. 81 | */ 82 | MeanAverage, 83 | 84 | /** 85 | * This method is the simplest way to represent a cluster. It places the cluster at the first location in the cluster. This method may not accurately 86 | * represent the data but requires little processing power. 87 | */ 88 | FirstLocation 89 | } 90 | 91 | /** 92 | * This class extends the Pushpin class and has all the same methods and properties plus the following properties. 93 | * @requires The Microsoft.Maps.Clustering module. 94 | */ 95 | export class ClusterPushpin extends Pushpin { 96 | /** An array of all the pushpins that are in the cluster. */ 97 | containedPushpins: Pushpin[]; 98 | 99 | /** 100 | * The grid cell key that can be used retrieve the clustered pushpin(s) from the clustering layer. This is useful when creating a clickable list that 101 | * link items in the list to clusters or pushpins on the map. Your list just needs to store the gridKey value. 102 | */ 103 | gridKey: number; 104 | } 105 | 106 | /** 107 | * This class allows you to easily add in client side clustering to your application. Client Side Clustering is a method where pushpins that are close 108 | * together are grouped and represented as a single pushpin, often using a different icon to indicate the cluster. This is a great way to improve both 109 | * the user experience and performance of the map. 110 | * @requires The Microsoft.Maps.Clustering module. 111 | */ 112 | export class ClusterLayer implements IDataLayer { 113 | /** 114 | * @constructor 115 | * @requires The Microsoft.Maps.Clustering module. 116 | * @param pushpins An array of pushpins to cluster in the layer. 117 | * @param options The options used to customize how the ClusterLayer functions. 118 | */ 119 | constructor(pushpins: Pushpin[], options?: IClusterLayerOptions); 120 | 121 | /** Clears all the data in the cluster layer. */ 122 | public clear(): void; 123 | 124 | /** 125 | * Gets all the pushpins that are in the current map view. If clustering is disabled, all pushpins in the clustering layer are returned. 126 | * @returns All the pushpins that are in the current map view. If clustering is disabled, all pushpins in the clustering layer are returned. 127 | */ 128 | public getDisplayedPushpins(): Pushpin[]; 129 | 130 | /** 131 | * Gets the current options used by the cluster layer. 132 | * @returns The current options used by the cluster layer. 133 | */ 134 | public getOptions(): IClusterLayerOptions; 135 | 136 | /** 137 | * Gets all pushpins that are in the layers. 138 | * @returns An array of all the pushpins that are in the layers. 139 | */ 140 | public getPushpins(): Pushpin[]; 141 | 142 | /** 143 | * Gets the original pushpins that are in the specified grid cell. 144 | * @param The gridKey index to retrieve the pushpins for. 145 | * @returns The original pushpins that are in the specified grid cell. 146 | */ 147 | public getPushpinsByGridKey(gridKey: number): Pushpin[]; 148 | 149 | /** 150 | * Gets the pushpin in the specified cluster grid cell which can be either a ClusterPushpin if there are multiple pushpins in a cell or a single Pushpin. 151 | * @param The gridKey index to retrieve the pushpins for. 152 | * @returns The pushpin in the specified cluster grid cell which can be either a ClusterPushpin if there are multiple pushpins in a cell or a single Pushpin. 153 | */ 154 | public getClusterPushpinByGridKey(gridKey: number): ClusterPushpin | Pushpin; 155 | 156 | /** 157 | * Sets the clustering options to use in the layer. 158 | * @params options The clustering options to use in the layer. 159 | */ 160 | public setOptions(options: IClusterLayerOptions): void; 161 | 162 | /** 163 | * Sets the array of pushpins that are used in the clustering layer. 164 | * @param pushpins An array of pushpins that are to be used by the clustering layer. 165 | */ 166 | public setPushpins(pushpins: Pushpin[]): void; 167 | } 168 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!WARNING] 2 | > **Bing Maps for Enterprise is deprecated and will be retired** 3 | > * Enterprise account customers can continue to use Bing Maps for Enterprise services **until June 30th, 2028**. 4 | > * Free (Basic) account customers can continue to use Bing Maps for Enterprise services until **June 30th, 2025**. 5 | > * To avoid service disruptions, all implementations using Bing Maps for Enterprise REST APIs and SDKs will need to be updated to use [Azure Maps](https://azuremaps.com) by the retirement date that applies to your Bing Maps for Enterprise account type. 6 | > * For migration documentation, please see [Bing Maps Migration Overview](https://learn.microsoft.com/azure/azure-maps/migrate-bing-maps-overview). 7 | > * For more details on the retirement, see the [announcement](https://aka.ms/BMERetirementAnnouncement) on the Bing Maps Blog. 8 | 9 | ![Bing Maps Logo](images/BingMapsLogoTeal.png) 10 | 11 | [![NuGet](https://img.shields.io/badge/NuGet-2.0.3-blue.svg)](https://www.nuget.org/packages/Microsoft.BingMaps.V8.TypeScript/) 12 | [![npm](https://img.shields.io/badge/npm-2.0.3-red.svg)](https://www.npmjs.com/package/bingmaps) 13 | [![license](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE.md) 14 | 15 | # Bing Maps V8 TypeScript Definitions # 16 | 17 | These are the official TypeScript definitions for the [Bing Maps V8 Web Control](https://msdn.microsoft.com/en-US/library/mt712542.aspx). These can be used to provide intellisense and richer error catching functionality to your IDE. 18 | 19 | ![Bing Maps V8 Intellisense](images/V8Intellisense.gif "Bing Maps V8 Intellisense") 20 | 21 | **Note:** Due to popular demand, version 2.x now puts these definitions in a _**types**_ folder instead of a _**scripts**_ folder. 22 | 23 | ## How to get the definitions ## 24 | 25 | **Use the NuGet Package** 26 | 27 | Using the [Bing Maps V8 TypeScript Definitions NuGet package](https://www.nuget.org/packages/Microsoft.BingMaps.V8.TypeScript/) will make it easy to both add the definitions to your project and to also keep them up to date. 28 | 29 | If using Visual Studio, open the nuget package manager, select the Browse tab and search for "Bing Maps V8". This should reduce the list of results enough to fine the "Bing Maps V8 TypeScript Definitions" package. The owner of the package is bingmaps. 30 | 31 | Alternatively, if you are using the nuget commandline: 32 | 33 | ``` 34 | PM> Install-Package Microsoft.BingMaps.V8.TypeScript 35 | ``` 36 | 37 | **Install npm package** 38 | 39 | Using the [Bing Maps V8 TypeScript npm package](https://www.npmjs.com/package/bingmaps) is another easy way to add the definitions to your project and keep them up to date. 40 | 41 | ``` 42 | npm install -g bingmaps 43 | ``` 44 | **Download definitions** 45 | 46 | Simply press the download button for this repository. Unzip the downloaded file, and copy the _**types**_ folder into your project. Note that you will need to do this process again from time to time if you want to have the most recent definitions. This should only be needed if you want to use newer features or if bugs in the definitions have been corrected. 47 | 48 | ## Usage ## 49 | 50 | If using Visual Studio, you can add a reference to the core Bing Maps V8 functionality by adding the following to the top of your TypeScript file. 51 | 52 | ``` 53 | /// 54 | /// 55 | ``` 56 | 57 | If you want to also use some of the Bing Maps modules, you can either update the above reference to the following: 58 | 59 | ``` 60 | /// 61 | ``` 62 | 63 | or you can add a reference to the individual module definitions. 64 | 65 | | Module | Path | 66 | |---------------------------------------------------------------------------------|----------------------------------------------------------| 67 | | [Autosuggest](https://msdn.microsoft.com/en-us/library/mt712650.aspx) | types/MicrosoftMaps/Modules/Autosuggest.d.ts | 68 | | [Clustering](https://msdn.microsoft.com/en-us/library/mt712807.aspx) | types/MicrosoftMaps/Modules/Clustering.d.ts | 69 | | [Contour](https://msdn.microsoft.com/en-us/library/mt786479.aspx) | types/MicrosoftMaps/Modules/Contour.d.ts | 70 | | [Data Binning](https://msdn.microsoft.com/en-us/library/mt743067.aspx) | types/MicrosoftMaps/Modules/DataBinning.d.ts | 71 | | [Directions](https://msdn.microsoft.com/en-US/library/mt748655.aspx) | types/MicrosoftMaps/Modules/Directions.d.ts | 72 | | [Drawing Tools](https://msdn.microsoft.com/en-us/library/mt750543.aspx) | types/MicrosoftMaps/Modules/DrawingTools.d.ts | 73 | | [GeoJSON](https://msdn.microsoft.com/en-us/library/mt712806.aspx) | types/MicrosoftMaps/Modules/GeoJson.d.ts | 74 | | [GeoXml](https://msdn.microsoft.com/en-us/library/mt825057.aspx) | types/MicrosoftMaps/Modules/GeoXml.d.ts | 75 | | [Heat Map Layer](https://msdn.microsoft.com/en-us/library/mt712868.aspx) | types/MicrosoftMaps/Modules/HeatMapLayer.d.ts | 76 | | [Search](https://msdn.microsoft.com/en-us/library/mt712846.aspx) | types/MicrosoftMaps/Modules/Search.d.ts | 77 | | [Spatial Data Services](https://msdn.microsoft.com/en-us/library/mt712849.aspx) | types/MicrosoftMaps/Modules/SpatialDataServices.d.ts | 78 | | [Spatial Math](https://msdn.microsoft.com/en-us/library/mt712834.aspx) | types/MicrosoftMaps/Modules/SpatialMath.d.ts | 79 | | [Traffic](https://msdn.microsoft.com/en-us/library/mt712860.aspx) | types/MicrosoftMaps/Modules/Traffic.d.ts | 80 | | [Well Known Text](https://msdn.microsoft.com/en-us/library/mt712880.aspx) | types/MicrosoftMaps/Modules/WellKnownText.d.ts | 81 | 82 | **Note:** 83 | 84 | This project is just TypeScript definitions and not actual API code. You will need to add a script reference to the Bing Maps V8 Web Control in your application to load the functional API. For example: 85 | 86 | ``` 87 | 88 | ``` 89 | 90 | ## Screenshots ## 91 | 92 | The following shows the intellisense for events. Notice how a list of the supported events are displayed, thus saving you from having to go back to documentation to verify the correct event name. Also notice how the structure of the event argument is known and you can easily access its properties. 93 | 94 | ![Bing Maps V8 Event Intellisense](images/V8EventIntellisense.gif "Bing Maps V8 Event Intellisense") 95 | 96 | The following shows the intellisense for adding modules. A list of the supported modules appears, saving you from having to go looking for the correct name/spelling used in Bing Maps V8. 97 | 98 | ![Bing Maps V8 Load Module Intellisense](images/V8LoadModuleIntellisense.gif "Bing Maps V8 Load Module Intellisense") 99 | 100 | ## Q & A ## 101 | 102 | - **Q: When will new Bing Maps features be added to these definitions.** 103 | - **A:** New features will be added to the definitions when they have graduated out of the experimental branch and into the main release branch of V8. This will often be done in parallel with MSDN documentation updates. A list of new features can be found in the release notes [here](https://msdn.microsoft.com/en-US/library/mt770019.aspx). 104 | - **Q: Whats the difference between version 1.x and 2.x?** 105 | - **A:** Version one put all the definitions in a _**scripts**_ folder while version 2.x adds them to a _**types**_ folder. 106 | 107 | ## Contributing ## 108 | 109 | We welcome contributions. Feel free to file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our [Contribution Rules & Guidelines](CONTRIBUTING.md). 110 | 111 | You can reach out to us anytime with questions and suggestions using our communities below: 112 | * [MSDN Forums](https://social.msdn.microsoft.com/Forums/en-US/home?forum=bingmapsajax&filter=alltypes&sort=lastpostdesc) 113 | * [StackOverflow](http://stackoverflow.com/questions/tagged/bing-maps) 114 | 115 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 116 | 117 | ## Related Projects ## 118 | 119 | * [Bing Maps V8 Code Samples](https://github.com/Microsoft/BingMapsV8CodeSamples) 120 | * [Bing Maps Android](https://github.com/LeonidVeremchuk/BingMapAndroid) 121 | 122 | ## Additional Resources ## 123 | 124 | * [Bing Maps V8 Interactive Code Samples](http://www.bing.com/api/maps/sdk/mapcontrol/isdk) 125 | * [Bing Maps V8 MSDN Documentation](https://msdn.microsoft.com/en-us/library/mt712542.aspx) 126 | * [Bing Maps Blog](http://blogs.bing.com/maps) 127 | * [Bing Maps forums](https://social.msdn.microsoft.com/Forums/en-US/home?forum=bingmapsajax&filter=alltypes&sort=lastpostdesc) 128 | * [Bing Maps for Enterprise site](https://www.microsoft.com/maps/) 129 | 130 | ## License ## 131 | 132 | MIT 133 | 134 | See [License](LICENSE.md) for full license text. 135 | -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Search.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | /** 28 | * Provides an easy method for geocoding address and searching for points of interest from JavaScript. 29 | * @requires The Microsoft.Maps.Search module. 30 | */ 31 | declare module Microsoft.Maps.Search { 32 | 33 | /** 34 | * Defines the geocoding level of the location match found by the geocoder. 35 | * @requires The Microsoft.Maps.Search module. 36 | */ 37 | export enum MatchCode { 38 | /** No match was found. */ 39 | none, 40 | 41 | /** The match was good. */ 42 | good, 43 | 44 | /** The match was ambiguous. Multiple results were returned. */ 45 | ambiguous, 46 | 47 | /** The match was found by a broader search. */ 48 | upHierarchy, 49 | 50 | /** The match was found, but possibly using a modified query. */ 51 | modified 52 | } 53 | 54 | /** 55 | * Defines the confidence of the location match found by the geocoding service. 56 | * @requires The Microsoft.Maps.Search module. 57 | */ 58 | export enum MatchConfidence { 59 | /** The confidence of the match is high. */ 60 | high, 61 | 62 | /** The confidence of the match is medium. */ 63 | medium, 64 | 65 | /** The confidence of the match is low. */ 66 | low, 67 | 68 | /** The confidence of the match is unknown. */ 69 | unknown 70 | } 71 | 72 | /** An object that represents a geocoded location. */ 73 | export interface IGeocodeLocation { 74 | /** The latitude of the location. */ 75 | latitude: number; 76 | 77 | /** The longitude of the location. */ 78 | longitude: number; 79 | 80 | /** The name of this geocode location match. */ 81 | name: string; 82 | 83 | /** 84 | * The precision of this geocode location match. 85 | * Possible Values: Interpolated, InterpolatedOffset, Rooftop, Parcel 86 | */ 87 | precision: string ; 88 | } 89 | 90 | /** An object that represents an place result. */ 91 | export interface IPlaceResult { 92 | /** The geocoded address of the place result. */ 93 | address: IAddress; 94 | 95 | /** The location rectangle that defines the boundaries of the best map view of the place result. */ 96 | bestView: LocationRect; 97 | 98 | /** The classification of the geographic entity returned, such as PopulatedPlace. */ 99 | entityType: string; 100 | 101 | /** The geocoded location of the best result. */ 102 | location: Location; 103 | 104 | /** The geocoded locations. */ 105 | locations: IGeocodeLocation[]; 106 | 107 | /** The match code of the best result. */ 108 | matchCode: string | MatchCode; 109 | 110 | /** The match confidence of the best result. */ 111 | matchConfidence: string | MatchConfidence; 112 | 113 | /** The name of the place result, if one exists. */ 114 | name: string; 115 | } 116 | 117 | /** An object that represents a geocode result returned by REST service. */ 118 | export interface IGeocodeResult { 119 | /** An array of geocode results. */ 120 | results: IPlaceResult[]; 121 | } 122 | 123 | /** The options for a geocode request. */ 124 | export interface IGeocodeRequestOptions { 125 | /** 126 | * A location rectangle that defines the boundaries of the area in which to search for 127 | * location results. The default is the bounds of the map view associated with this 128 | * instance of the SearchManager, which is usually the current map view. 129 | */ 130 | bounds?: LocationRect; 131 | 132 | /** 133 | * The name of the function to call when a successful result is returned from the 134 | * geocode request. The callback function must accept two parameters: result, which is 135 | * a GeocodeResult type, and a userData object. 136 | */ 137 | callback: (geocodeResult: IGeocodeResult, userData: any) => void; 138 | 139 | /** The maximum number of results to return. Required. The maximum number than can be returned is 20. */ 140 | count?: number; 141 | 142 | /** 143 | * The name of the function to call when the request is returned with an error. The 144 | * error callback function must accept an IGeocodeRequestOptions object. 145 | */ 146 | errorCallback?: (geocodeRequestOptions: IGeocodeRequestOptions) => void; 147 | 148 | /** Specifies to include the two-letter ISO country code. */ 149 | includeCountryIso2?: boolean; 150 | 151 | /** Specifies to include the neighborhood in the response when it is available. */ 152 | includeNeighborhood?: boolean; 153 | 154 | /** A number indicating how long to wait, in seconds, for the geocode request to return. The default value is 5 seconds. */ 155 | timeout?: number; 156 | 157 | /** An object containing any data that needs to be passed to the callback when the request is completed. */ 158 | userData?: any; 159 | 160 | /** A string containing the address or place to be matched to a location on the map. */ 161 | where: string; 162 | } 163 | 164 | /** The options for a reverse geocode request. */ 165 | export interface ReverseGeocodeRequestOptions { 166 | /** 167 | * A reference to a function to call when a successful result is returned from the geocode request. The callback function 168 | * will receive a PlaceResult object as an argument. 169 | */ 170 | callback: (placeResult: IPlaceResult, userData: any) => void; 171 | 172 | /** 173 | * A reference to a function to call when the request is returned with an error. The error callback function will receive 174 | * an object containing the geocode request options used in the request. 175 | */ 176 | errorCallback?: (reverseGeocodeRequestOptions: ReverseGeocodeRequestOptions) => void; 177 | 178 | /** Specifies to include the two-letter ISO country code. Default: false */ 179 | includeCountryIso2?: boolean; 180 | 181 | /** 182 | * An array of entity types selected from the following options. 183 | * • Address 184 | * • Neighborhood 185 | * • PopulatedPlace 186 | * • Postcode1 187 | * • AdminDivision1 188 | * • AdminDivision2 189 | * • CountryRegion 190 | * These entity types are ordered from the most specific entity to the least specific entity. When entities of more than one entity type are found, only the most specific 191 | * entity is returned. For example, if you specify Address and AdminDistrict1 as entity types and entities were found for both types, only the Address entity information is 192 | * returned in the response. One exception to this rule is when both PopulatedPlace and Neighborhood entity types are specified and information is found for both. In this case, 193 | * the information for both entity types is returned. Also, more than one Neighborhood may be returned because the area covered by two different neighborhoods can overlap. 194 | */ 195 | includeEntityTypes?: string[]; 196 | 197 | /** 198 | * Specifies to include the neighborhood in the response when it is available. Note: This feature isn’t 199 | * available in all locations. 200 | */ 201 | includeNeighborhood?: boolean; 202 | 203 | /** The location to use to match to geographic entities and addresses. */ 204 | location: Location; 205 | 206 | /** A number indicating how long to wait, in seconds, for the reverse geocode request to return. The default value is 5 seconds. */ 207 | timeout?: number; 208 | 209 | /** An object containing any data that needs to be passed to the callback when the request is completed. */ 210 | userData?: any; 211 | } 212 | 213 | /** 214 | * A class that contains methods for returning search and location results. 215 | * @requires The Microsoft.Maps.Search module. 216 | */ 217 | export class SearchManager { 218 | /** 219 | * @constructor 220 | * @requires The Microsoft.Maps.Search module. 221 | * @param map A Map object 222 | */ 223 | constructor(map: Map); 224 | 225 | /** 226 | * Matches the address or place query in the specified request 227 | * options to a location and returns the results to the request 228 | * options callback function. 229 | * @param request Options for sending geocode request 230 | */ 231 | public geocode(request: IGeocodeRequestOptions): void; 232 | 233 | /** 234 | * Matches the specified location to an address and returns the 235 | * address results to the specified request options callback function. 236 | * @param request Options for sending reverse geocode request 237 | */ 238 | public reverseGeocode(request: ReverseGeocodeRequestOptions): void; 239 | } 240 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/DrawingTools.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | 29 | /** An object that contains the event arguments for when the drawing mode changes in the drawing tools. **/ 30 | export interface IDrawingModeChangedData { 31 | 32 | /** The shape being modified by the drawing tools. **/ 33 | shape: IPrimitive; 34 | 35 | /** The new drawing mode. **/ 36 | mode: DrawingTools.DrawingMode; 37 | } 38 | 39 | /** 40 | * Collection of options for the various DrawingTool methods 41 | */ 42 | export interface IDrawingToolOptions { 43 | /** Set of buttons to show in the drawing bar */ 44 | drawingBarActions?: DrawingTools.DrawingBarAction; 45 | } 46 | 47 | /** An object that contains options to change the settings of the drawing manager. */ 48 | export interface IDrawingManagerOptions extends IDrawingToolOptions { 49 | /** Set of buttons to show in the drawing bar. */ 50 | drawingBarActions?: DrawingTools.DrawingBarAction; 51 | 52 | /** The fill color used for pushpins and polygons. */ 53 | fillColor?: string | Color; 54 | 55 | /** The stroke color used for polylines and polygons. */ 56 | strokeColor?: string | Color; 57 | } 58 | 59 | /** 60 | * The DrawingManager class manages the ability to draw and edit multiple shapes on the map. Shapes managed by this class are rendered on a separate drawing layer. 61 | * User can use a mouse or a touch screen to draw on the map. When they are done, pressing the escape button or any button on the toolbar will exit the current drawing mode. 62 | * This class does not have a publicly accessible constructor and can only be accessed using the showDrawingManager of the DrawingTools class. 63 | */ 64 | export interface DrawingManager { 65 | /** 66 | * Adds a shapes to the layer, at the specified index if specified. 67 | • @param data The shape(s) to be added to the layer. 68 | • @param index The index at which to insert the shape into the layer. 69 | */ 70 | add(data: IPrimitive | IPrimitive[], index?: number): void; 71 | 72 | /** 73 | * Disposes the drawing manager instance. 74 | */ 75 | dispose(): void; 76 | 77 | /** 78 | * Resets the drawing manager and clears all shapes in the drawing layer. 79 | */ 80 | clear(): void; 81 | 82 | /** 83 | * Gets the current drawing mode of the drawing manager. 84 | * @returns The current drawing mode of the drawing manager. 85 | */ 86 | getDrawingMode(): DrawingTools.DrawingMode; 87 | 88 | /** 89 | * Gets an array of shapes that are in the layer. This can be used to iterate over the individual shapes. 90 | * @returns An array of shapes that are in the layer. This can be used to iterate over the individual shapes. 91 | */ 92 | getPrimitives(): IPrimitive[]; 93 | 94 | /** 95 | * Returns the index of the shape in the drawing layer. 96 | * @param primitive The shape to find the index of. 97 | * @param fromIndex The index to start the search from. 98 | * @returns The index of the shape in the drawing layer. Returns -1 if shape is not found. 99 | */ 100 | indexOf(primitive: IPrimitive, fromIndex?: number): number; 101 | 102 | /** 103 | * Removes a shape from the layer and returns it. 104 | * @param primitive The shape to remove from the layer. 105 | * @returns The shape that was removed from the layer. 106 | */ 107 | remove(primitive: IPrimitive): IPrimitive; 108 | 109 | /** 110 | * Removes a shape from the layer at the specified index. 111 | * @param index The index of the shape to remove from the layer. 112 | * @returns The shape that was removed from the layer. 113 | */ 114 | removeAt(index: number): IPrimitive; 115 | 116 | /** 117 | * Sets the drawing mode of the drawing manager. 118 | * @param mode The drawing mode to set the DrawingManager to. 119 | */ 120 | setDrawingMode(mode: DrawingTools.DrawingMode): void; 121 | 122 | /** 123 | * Sets the drawing tool options. 124 | * @param options The options to use with the drawing manager. 125 | */ 126 | setOptions(options: IDrawingManagerOptions): void; 127 | 128 | /** 129 | * Replaces all shapes in the layer with the new array of shapes that have been provided. 130 | * @param primitives An array of shapes to add to the drawing layer. 131 | */ 132 | setPrimitives(primitives: IPrimitive[]): void; 133 | } 134 | 135 | /** 136 | * Provides a set of tools for drawing and editing shapes on top of the map. 137 | * @requires The Microsoft.Maps.DrawingTools module. 138 | */ 139 | export class DrawingTools { 140 | /** 141 | * @constructor 142 | * @requires The Microsoft.Maps.DrawingTools module. 143 | * @param map A map instanct to attach the drawing tools to. 144 | */ 145 | constructor(map: Map); 146 | 147 | /** 148 | * Initializes the drawing layer and instructs it to create a new shape of a given type. 149 | * @param shapeType The type of new shape to create. 150 | * @param created A callback function that is fired after the initial shape is created. 151 | */ 152 | public create(shapeType: DrawingTools.ShapeType, created?: (shape: IPrimitive) => void): void; 153 | 154 | /** Disposes the instance of the DrawingTools class. */ 155 | public dispose(): void; 156 | 157 | /** 158 | * Adds a shape to the drawing layer and puts it into edit mode. 159 | * @param shape A shape to put into editting mode. 160 | */ 161 | public edit(shape: IPrimitive): void; 162 | 163 | /** 164 | * Finishes any shape create / edit operation currently in progress, and returns the shape that was created or editted through a specified callback function. 165 | * @param finished A callback function to return the completed shape with. 166 | */ 167 | public finish(finished?: (shape: IPrimitive) => void): void; 168 | 169 | /** 170 | * Shows the drawing toolbar, if it isn't already visible. 171 | * @param options - Options for this DrawingTool operation. Specifically, 172 | * the drawingBarActions property is used to customize the drawing bar view. 173 | */ 174 | public showDrawingBar(options?: IDrawingToolOptions): void; 175 | 176 | /** 177 | * Creates a drawing manager which allows multi-shape editing and displays the toolbar. 178 | * @param callback A callback function that is triggered after the DrawingTools have loaded. 179 | */ 180 | public showDrawingManager(callback?: (manager: DrawingManager) => void): void; 181 | } 182 | 183 | export module Events { 184 | ///////////////////////////////////// 185 | /// addHandler Definitions 186 | //////////////////////////////////// 187 | 188 | /** 189 | * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. 190 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 191 | * @param eventName The type of event to attach. Supported Events: 192 | * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted 193 | * @param handler The callback function to handle the event when triggered. 194 | * @returns The handler id. 195 | */ 196 | export function addHandler(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): IHandlerId; 197 | 198 | /** 199 | * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. 200 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 201 | * @param eventName The type of event to attach. Supported Events: 202 | * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted 203 | * @param handler The callback function to handle the event when triggered. 204 | * @returns The handler id. 205 | */ 206 | export function addHandler(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void): IHandlerId; 207 | 208 | ///////////////////////////////////// 209 | /// addOne Definitions 210 | //////////////////////////////////// 211 | 212 | /** 213 | * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. 214 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 215 | * @param eventName The type of event to attach. Supported Events: 216 | * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted 217 | * @param handler The callback function to handle the event when triggered. 218 | */ 219 | export function addOne(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): void; 220 | 221 | /** 222 | * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. 223 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 224 | * @param eventName The type of event to attach. Supported Events: 225 | * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted 226 | * @param handler The callback function to handle the event when triggered. 227 | */ 228 | export function addOne(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void): void; 229 | 230 | ///////////////////////////////////// 231 | /// addThrottledHandler Definitions 232 | //////////////////////////////////// 233 | 234 | /** 235 | * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. 236 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 237 | * @param eventName The type of event to attach. Supported Events: 238 | * drawingChanged, drawingChanging, drawingEnded, drawingModeChanged, drawingStarted 239 | * @param handler The callback function to handle the event when triggered. 240 | * @returns The handler id. 241 | */ 242 | export function addThrottledHandler(target: DrawingTools, eventName: string, handler: (eventArg?: IPrimitive | IDrawingModeChangedData) => void): IHandlerId; 243 | 244 | /** 245 | * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. 246 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 247 | * @param eventName The type of event to attach. Supported Events: 248 | * disposed, drawingChanged, drawingChanging, drawingEnded, drawingErased, drawingModeChanged, drawingStarted 249 | * @param handler The callback function to handle the event when triggered. 250 | * @param throttleInterval throttle interval (in ms) 251 | * @returns The handler id. 252 | */ 253 | export function addThrottledHandler(target: DrawingManager, eventName: string, handler: (eventArg?: IPrimitive | DrawingTools.DrawingMode) => void, throttleInterval: number): IHandlerId; 254 | } 255 | } 256 | 257 | declare module Microsoft.Maps.DrawingTools { 258 | /** 259 | * The different drawing modes that the drawing manager can be set to. 260 | * @requires The Microsoft.Maps.DrawingTools module. 261 | */ 262 | export enum DrawingMode { 263 | /** Edit an existing shape. Click on a shape to edit it. */ 264 | edit, 265 | 266 | /** Erase and existing shape. Click on the shapes to erase them. */ 267 | erase, 268 | 269 | /** Sets the drawing manager into an idle mode. */ 270 | none, 271 | 272 | /** Allow the user to draw a polygon. */ 273 | polygon, 274 | 275 | /** Allow the user to draw a polyline. */ 276 | polyline, 277 | 278 | /** Allow the user to draw a pushpin. */ 279 | pushpin 280 | } 281 | 282 | /** 283 | * The different types of shapes that are created or edited by the drawing tools. 284 | * @requires The Microsoft.Maps.DrawingTools module. 285 | */ 286 | export enum ShapeType { 287 | /** A polygon shape type. */ 288 | polygon, 289 | 290 | /** A polyline shape type. */ 291 | polyline 292 | } 293 | 294 | /** 295 | * Values used to identify and enable the items shown in the drawing bar. 296 | */ 297 | export enum DrawingBarAction { 298 | /** Create point primitive */ 299 | point, 300 | 301 | /** Create polyline primitive */ 302 | polyline, 303 | 304 | /** Create polygon primitive */ 305 | polygon, 306 | 307 | /** Erase existing primitive */ 308 | erase, 309 | 310 | /** Edit existing primitive */ 311 | edit, 312 | 313 | /** Change stroke style */ 314 | strokeStyle, 315 | 316 | /** Change fill style */ 317 | fillStyle, 318 | 319 | /** All items */ 320 | all, 321 | 322 | /** All shape creation items */ 323 | createShapes, 324 | 325 | /** All shape editing items */ 326 | editShapes, 327 | 328 | /** All shape styling items */ 329 | styleShapes 330 | } 331 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/GeoXml.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps { 28 | 29 | /** 30 | * An enumeration of different GeoXML file formats. 31 | * @requires The Microsoft.Maps.GeoXml module. 32 | */ 33 | export enum GeoXmlFormat { 34 | /** A KML XML file format. */ 35 | kml, 36 | 37 | /** A GPX XML file format. */ 38 | gpx, 39 | 40 | /** A GeoRSS XML file using ATOM format. */ 41 | geoRss 42 | } 43 | 44 | /** 45 | * An enumeration of the different compressed formats that XML can be outputted as. 46 | * @requires The Microsoft.Maps.GeoXml module. 47 | */ 48 | export enum GeoXmlCompressedFormat { 49 | /** XML data compressed into a Base64 Data URI. */ 50 | base64, 51 | 52 | /** XML data compressed into a Blob. */ 53 | blob, 54 | 55 | /** XML data compressed into an ArrayBuffer. */ 56 | arrayBuffer 57 | } 58 | 59 | /** 60 | * A GeoXML result data set that is returned when reading a spatial XML file. 61 | */ 62 | export interface IGeoXmlDataSet { 63 | /** An array of shapes that are in the XML document. */ 64 | shapes?: IPrimitive[]; 65 | 66 | /** 67 | * An array of layers that are in the XML document. 68 | * In shapes in KML that are in a child documents and folders of the main document or folder are grouped together in a data Layer. 69 | * KML also supports GroundOverlay. 70 | */ 71 | layers?: (Layer | GroundOverlay)[]; 72 | 73 | /** 74 | * An array of screen overlays that have been parsed from a KML file. 75 | */ 76 | screenOverlays?: KmlScreenOverlay[]; 77 | 78 | /** 79 | * Summary metadata provided at the document level of the XML feed data set. 80 | */ 81 | summary?: IGeoXmlSummaryMetadata; 82 | 83 | /** 84 | * Statistics about the content and processing time of a XML feed. 85 | */ 86 | stats?: IGeoXmlStats; 87 | } 88 | 89 | /** 90 | * Options used to customize how a GeoXmlLayer renders. 91 | */ 92 | export interface IGeoXmlLayerOptions extends IGeoXmlReadOptions { 93 | /** A boolean indicating if the map should automatically upate the view when a data set is loaded. Default: true */ 94 | autoUpdateMapView?: boolean; 95 | 96 | /** Options used to customize how the default infobox renders. */ 97 | infoboxOptions?: Microsoft.Maps.IInfoboxOptions; 98 | 99 | /** A boolean indicating if infoboxes should automatically appear when shapes clicked. Default: false */ 100 | suppressInfoboxes?: boolean; 101 | 102 | /** A boolean indicating if the layer is visible or not. Default: true */ 103 | visible?: boolean; 104 | 105 | /** An optional name to identify the layer by. */ 106 | layerName?: string; 107 | } 108 | 109 | /** 110 | * Options that customize how XML files are read and parsed. 111 | */ 112 | export interface IGeoXmlReadOptions { 113 | /** Specifies if KML ScreenOverlays should be read or ignored. Default: true */ 114 | allowKmlScreenOverlays?: boolean; 115 | 116 | /** 117 | * A callback function that is triggered when an error occurs when reading an XML document. 118 | */ 119 | error?: (msg: string) => void; 120 | 121 | /** 122 | * Specifies wether the individual waypoint data of a GPX Route or Track should be captured. 123 | * If set to true, the shape will have a metadata.waypoints property that is an array of 124 | * pushpins that contains the details of each waypoint along the track. Default: false 125 | */ 126 | captureGpxPathWaypoints?: boolean; 127 | 128 | /** The default styles to apply to shapes that don't have a defined style in the XML. */ 129 | defaultStyles?: IStylesOptions; 130 | 131 | /** Specifies if shapes visible tags should be used to set the visible property of it's equivalent Bing Maps shape. Default: true */ 132 | ignoreVisibility?: boolean; 133 | 134 | /** 135 | * The maximium number of network links that a single KML file can have. Default: 10. 136 | */ 137 | maxNetworkLinks?: number; 138 | 139 | /** 140 | * The maximium depth of network links in a KML file. Default: 3 141 | * Example: when set to 3; file1 links to file2 which links to file3 but won't open links in file3. 142 | */ 143 | maxNetworkLinkDepth?: number; 144 | 145 | /** Indicates if the pushpin title should be displayed on the map if a valid title or name value exits in the shapes metadata. Default: true */ 146 | setPushpinTitles?: boolean; 147 | } 148 | 149 | /** 150 | * Statistics about the content and processing time of a XML feed. 151 | */ 152 | export interface IGeoXmlStats { 153 | /** Number of Microsoft.Maps.Pushpins objects in the XML feed. */ 154 | numPushpins: number; 155 | 156 | /** Number of Microsoft.Maps.Polylines objects in the XML feed. */ 157 | numPolylines: number; 158 | 159 | /** Number of Microsoft.Maps.Polygons objects in the XML feed. */ 160 | numPolygons: number; 161 | 162 | /** Number of Microsoft.Maps.Location objects in the XML feed. */ 163 | numLocations: number; 164 | 165 | /** Number of Ground Overlays in the XML feed. */ 166 | numGroundOverlays: number; 167 | 168 | /** Number of Screen Overlays in the XML feed. */ 169 | numScreenOverlays: number; 170 | 171 | /** The number of network links in the XML feed. */ 172 | numNetworkLinks: number; 173 | 174 | /** The number of characters in the XML feed. */ 175 | fileSize: number; 176 | 177 | /** The amount of time in ms it took to process the XML feed. */ 178 | processingTime: number; 179 | } 180 | 181 | /** 182 | * Summary metadata provided at the document level of the XML feed data set. 183 | */ 184 | export interface IGeoXmlSummaryMetadata { 185 | /** The title or name of the content of the XML document. */ 186 | title?: string; 187 | 188 | /** The description of the content of the XML document. */ 189 | description?: string; 190 | 191 | /** The bounds of all the shapes and layers in the XML document. */ 192 | bounds?: LocationRect; 193 | 194 | /** Any additional metadata that the XML document may have. i.e. atom:author */ 195 | metadata?: IDictionary; 196 | } 197 | 198 | /** 199 | * Options that are used to customize how the GeoXml writes XML. 200 | */ 201 | export interface IGeoXmlWriteOptions { 202 | 203 | /** The characters to use to create an indent in the XML data. Default: \t */ 204 | indentChars?: string; 205 | 206 | /** The characters to use to create a new line in the XML data. Default: \r\n */ 207 | newLineChars?: string; 208 | 209 | /** A boolean indicating if the generated XML should be use new lines and indents to make the generated nicely formatted. Default: true */ 210 | prettyPrint?: boolean; 211 | 212 | /** A boolean indicating if Location and LocationRect values should be rounded off to 6 decimals. Default: false */ 213 | roundLocations?: boolean; 214 | 215 | /** 216 | * A boolean indicating if the shapes should be made valid before writing. If set to true, will use the 217 | * Geometry.makeValid function of the SpatialMath module. Default: false 218 | */ 219 | validate?: boolean; 220 | 221 | /** The XML format to write the shapes to. Default: Kml */ 222 | xmlFormat?: GeoXmlFormat; 223 | } 224 | 225 | /** 226 | * The options for customizing screen overlays. 227 | */ 228 | export interface IKmlScreenOverlayOptions { 229 | /** A boolean indicating if the screen overlay can be displayed above or beow the navigaiton bar. Default: false */ 230 | belowNavigationBar?: boolean; 231 | 232 | /** The visibility of the screen overlay. Default: true */ 233 | visible?: boolean; 234 | } 235 | 236 | /** 237 | * Overlays HTML elements winthin the map container that are above the map. 238 | * This is useful when adding logos, attributions or legends to the map. 239 | * This class is only used by the KML reader and not meant to be used on its own. 240 | * @requires The Microsoft.Maps.GeoXml module. 241 | */ 242 | export class KmlScreenOverlay { 243 | 244 | /** Optional property to store any additional metadata for this overlay. */ 245 | metadata: any; 246 | 247 | /** 248 | * @constructor 249 | * @param htmlElement The new htmlElement to set for the overlay. 250 | * @param options The options to customize the screen overlay. 251 | */ 252 | constructor(htmlElement?: string | HTMLElement, options?: IKmlScreenOverlayOptions); 253 | 254 | /** 255 | * Clears the screen overlay. 256 | */ 257 | public clear(): void; 258 | 259 | /** 260 | * Gets a boolean indicating if the screen overlay is displayed above or below the navigation bar. 261 | * @returns A boolean indicating if the screen overlay is displayed above or below the navigation bar. 262 | */ 263 | public getBelowNavigationBar(): boolean; 264 | 265 | /** 266 | * Gets the html element of this screen overlay. 267 | * @returns the htmlElement of this overlay. 268 | */ 269 | public getHtmlElement(): HTMLElement; 270 | 271 | /** 272 | * Returns the map that this overlay is attached to. 273 | * @returns The map that this overlay is attached to. 274 | */ 275 | public getMap(): Map; 276 | 277 | /** 278 | * Gets a boolean indicating if the screen overlay is visible or not. 279 | * @returns A boolean indicating if the screen overlay is visible or not. 280 | */ 281 | public getVisible(): boolean; 282 | 283 | /** 284 | * Updates the html element of this screen overlay. 285 | * @param htmlElement The new htmlElement to set for the overlay. 286 | */ 287 | public setHtmlElement(htmlElement: string | HTMLElement): void; 288 | 289 | /** 290 | * Sets the options to customize the screen overlay. 291 | * @param options The options to customize the screen overlay. 292 | */ 293 | public setOptions(options: IKmlScreenOverlayOptions): void; 294 | 295 | /** 296 | * Sets whether the overlay is visible or not. 297 | * @param value A value indicating if the overlay should be displayed or not. 298 | */ 299 | public setVisible(visible: boolean): void; 300 | } 301 | 302 | /** 303 | * A static class that contains functions for reading and writing geospatial XML data. 304 | * @requires The Microsoft.Maps.GeoXml module. 305 | */ 306 | export module GeoXml { 307 | 308 | /** 309 | * Takes a geospatial XML string or a ArrayBuffer and parses the XML data into Bing Maps shapes. 310 | * @param xml The XML as a string or ArrayBuffer to read. 311 | * @param options The read options. 312 | */ 313 | export function read(xml: string | ArrayBuffer, options: IGeoXmlReadOptions): IGeoXmlDataSet; 314 | 315 | /** 316 | * Takes an URL to an XML or zipped XML file and parses the XML data into Bing Maps shapes. 317 | * @param xml The URL to XML data to read. 318 | * @param options The read options. 319 | * @param callback The callback function that consumes the parsed out GeoXml data. 320 | */ 321 | export function readFromUrl(urlString: string, options: IGeoXmlReadOptions, callback: (data: IGeoXmlDataSet) => void): void; 322 | 323 | /** 324 | * Writes Bing Maps shape data as a geospatial XML string in the specified format. 325 | * @param shapes The Bing Maps shapes, or map to retrieve shapes from, to write. 326 | * @param options A set of options that customize how the XML is writen. 327 | */ 328 | export function write(shapes: Map | IPrimitive | IPrimitive[] | Layer | GroundOverlay[] | IGeoXmlDataSet, options?: IGeoXmlWriteOptions): string; 329 | 330 | /** 331 | * Writes Bing Maps shape data to a geospatial XML file embedded in a compressed file. 332 | * @param shapes The Bing Maps shapes, or map to retrieve shapes from, to write. 333 | * @param compressFormat The compressed file format to use. 334 | * @param options A set of options that customize how the XML is writen. 335 | */ 336 | export function writeCompressed(shapes: Map | IPrimitive | IPrimitive[] | Layer | GroundOverlay[] | IGeoXmlDataSet, compressFormat?: GeoXmlCompressedFormat, options?: IGeoXmlWriteOptions): string | ArrayBuffer | Blob; 337 | } 338 | 339 | /** 340 | * A layer that loads and renders geospatial XML data on the map. 341 | * @requires The Microsoft.Maps.GeoXml module. 342 | */ 343 | export class GeoXmlLayer extends Microsoft.Maps.CustomOverlay { 344 | 345 | /** Optional property to store any additional metadata for this layer. */ 346 | metadata: any; 347 | 348 | /** 349 | * @constructor 350 | * @param dataSource The XML as a string, URL or ArrayBuffer to read. 351 | * @param isUrl Whether the dataSource provided is an URL. Default = true 352 | * @param options The options used to render the layer. 353 | */ 354 | constructor(dataSource?: string | ArrayBuffer, isUrl?: boolean, options?: IGeoXmlLayerOptions); 355 | 356 | /** 357 | * Removes all the data in the layer. 358 | */ 359 | public clear(): void; 360 | 361 | /** 362 | * Cleans up any resources this object is consuming. 363 | */ 364 | public dispose(): void; 365 | 366 | /** 367 | * Returns the data source used by the layer. 368 | * @returns The data source used by the layer. 369 | */ 370 | public getDataSource(): string | ArrayBuffer; 371 | 372 | /** 373 | * Returns the data set that ws extracted from the data source. 374 | * @returns The data set that ws extracted from the data source. 375 | */ 376 | public getDataSet(): IGeoXmlDataSet; 377 | 378 | /** 379 | * Returns the options used by the GeoXmlLayer. 380 | * @returns The options used by the GeoXmlLayer. 381 | */ 382 | public getOptions(): IGeoXmlLayerOptions; 383 | 384 | /** 385 | * Gets a value indicating whether the layer is visible or not. 386 | * @returns A boolean indicating if the layer is visible or not. 387 | */ 388 | public getVisible(): boolean; 389 | 390 | /** 391 | * Sets the data source to render in the GeoXmlLayer. 392 | * @param dataSource The data source to render in the GeoXmlLayer. 393 | * @param isUrl Whether the dataSource provided is an URL. Default = true 394 | */ 395 | public setDataSource(dataSource: string | ArrayBuffer, isUrl: boolean): void; 396 | 397 | /** 398 | * Sets the options used for loading and rendering data into the GeoXmlLayer. 399 | * @param options The options to use when loading and rendering data into the GeoXmlLayer. 400 | */ 401 | public setOptions(options: IGeoXmlLayerOptions): void; 402 | 403 | /** 404 | * Sets whether the layer is visible or not. 405 | * @param value A value indicating if the layer should be displayed or not. 406 | */ 407 | public setVisible(visible: boolean): void; 408 | } 409 | 410 | 411 | export module Events { 412 | ///////////////////////////////////// 413 | /// addHandler Definitions 414 | //////////////////////////////////// 415 | 416 | /** 417 | * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. 418 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 419 | * @param eventName The type of event to attach. Supported Events: 420 | * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick 421 | * @param handler The callback function to handle the event when triggered. 422 | * @returns The handler id. 423 | */ 424 | export function addHandler(target: GeoXmlLayer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void): IHandlerId; 425 | 426 | ///////////////////////////////////// 427 | /// addOne Definitions 428 | //////////////////////////////////// 429 | 430 | /** 431 | * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. 432 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 433 | * @param eventName The type of event to attach. Supported Events: 434 | * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick 435 | * @param handler The callback function to handle the event when triggered. 436 | */ 437 | export function addOne(target: GeoXmlLayer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void): void; 438 | 439 | ///////////////////////////////////// 440 | /// addThrottledHandler Definitions 441 | //////////////////////////////////// 442 | 443 | /** 444 | * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. 445 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 446 | * @param eventName The type of event to attach. Supported Events: 447 | * click, dblclick, mousedown, mouseout, mouseover, mouseup, rightclick 448 | * @param handler The callback function to handle the event when triggered. 449 | * @returns The handler id. 450 | */ 451 | export function addThrottledHandler(target: GeoXmlLayer, eventName: string, handler: (eventArg?: IMouseEventArgs) => void): IHandlerId; 452 | } 453 | } 454 | -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/SpatialDataService.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | /** 28 | * This module wraps the Query and GeoData REST API’s in the Bing Spatial Dara Services and expose them as an easy to use JavaScript library. 29 | * @requires The Microsoft.Maps.SpatialDataService module. 30 | */ 31 | declare module Microsoft.Maps.SpatialDataService { 32 | 33 | ////////////////////////////////////////////// 34 | /// GeoData API 35 | ////////////////////////////////////////////// 36 | 37 | /** Represents the options for requests boundary data from the GeoData API in the Bing Spatial Data Services. */ 38 | export interface IGetBoundaryRequestOptions { 39 | /** 40 | * The level of detail for the boundary polygons returned. An integer between 0 and 3, where 0 specifies the coarsest level of boundary detail and 3 41 | * specifies the best. Default: 0 42 | */ 43 | lod?: number; 44 | 45 | /** 46 | * The entity type to return. Default: CountryRegion 47 | * Supported entity types: 48 | * AdminDivision1, AdminDivision2, CountryRegion, eighborhood, PopulatedPlace, Postcode1, Postcode2, Postcode3, Postcode4 49 | * Note: Not all entity types are available in all areas. 50 | */ 51 | entityType?: string; 52 | 53 | /** 54 | * Specifies the preferred language to use for any metadata text about the entity or polygons. Defaults to the culture used by the map control, which 55 | * usually automatically detected based on user's browser settings. Setting this property will override the default value. 56 | */ 57 | culture?: string; 58 | 59 | /** 60 | * Specifies whether the response should include all of the boundary polygons for the requested entity or just return a single polygon that represents 61 | * the main outline of the entity. Default: false 62 | */ 63 | getAllPolygons?: boolean; 64 | 65 | /** 66 | * Specifies whether the response should include metadata about the entity, such as AreaSqKm and others. Default: false 67 | */ 68 | getEntityMetadata?: boolean; 69 | 70 | /** 71 | * Specifies the user’s home country or region.Defaults to the region setting of the user who loads the map. 72 | * Warning: Setting this property will override the default value, which is the region the user is actually in, and will allow the user to see boundaries 73 | * which may not align with the views of their region.This could result in geopolitically sensitive borders being returned. 74 | */ 75 | userRegion?: string; 76 | } 77 | 78 | /** Represents the primitive object for a boundary returned by the GeoData API. */ 79 | export interface IGeoDataPrimitive { 80 | /** A unique ID associated with this polygon primitive. */ 81 | PrimitiveID: string; 82 | 83 | /** 84 | * A comma-delimited sequence starting with the version number of the polygon set followed by a list of compressed polygon 85 | * "rings" (closed paths represented by sequences of latitude and-longitude points). 86 | */ 87 | Shape: string; 88 | 89 | /** The number of vertex points used to define the polygon. */ 90 | NumPoints: string; 91 | 92 | /** 93 | * An ID identifying the data provider that supplied the data. This ID number will reference one of the sources listed in the 94 | * array of CopyrightSources in the Copyright property of the GeoDataResultSet object. 95 | */ 96 | SourceID: string; 97 | } 98 | 99 | /** Represents the copyright source object for a boundary returned by the GeoData API. */ 100 | export interface ICopyrightSource { 101 | /** The copyright string from the source. */ 102 | Copyright: string; 103 | 104 | /** An ID identifying the data provider that supplied the data. */ 105 | SourceID: string; 106 | 107 | /** The name of the data provider represented by this Source element. */ 108 | SourceName: string; 109 | } 110 | 111 | /** Represents the copyright object for a boundary returned by the GeoData API. */ 112 | export interface ICopyright { 113 | /** The copyright URL for the GeoData service. */ 114 | CopyrightURL: string; 115 | 116 | /** A collection of CopyrightSource objects that give information about the sources of the polygon data that is returned. */ 117 | Sources: ICopyrightSource[]; 118 | } 119 | 120 | /** Represents the name object for a boundary returned by the GeoData API. */ 121 | export interface IName { 122 | /** The name of boundary. Example: "United States" */ 123 | EntityName: string; 124 | 125 | /** The culture of the region. */ 126 | Culture: string; 127 | 128 | /** An ID identifying the data provider that supplied the data. */ 129 | SourceID: string; 130 | } 131 | 132 | /** Represents the metadata object for a boundary returned by the GeoData API. Not all properties will be returned for all results. */ 133 | export interface IMetadata { 134 | /** The approximate total surface area (in square kilometers) covered by all the polygons that comprise this entity. */ 135 | AreaSqKm: string; 136 | 137 | /** 138 | * An area on the Earth that provides the best map view for this entity. This area is defined as a bounding box in the format of a 139 | * “MULTIPOINT ((WestLongitude SouthLatitude), (EastLongitude NorthLatitude))”. 140 | */ 141 | BestMapViewBox: string; 142 | 143 | /** The culture associated with this entity. Example: en */ 144 | OfficialCulture: string; 145 | 146 | /** The approximate population within this entity. Example: PopClass20000to99999 */ 147 | PopulationClass: string; 148 | 149 | /** The regional culture associated with this entity. */ 150 | RegionalCulture: string; 151 | } 152 | 153 | /** Represents a single result object returned by the GeoData API. */ 154 | export interface IGeoDataResult { 155 | /** Copyright information for the returned boundary data. */ 156 | Copyright: ICopyright; 157 | 158 | /** A unique ID number associated with this entity. */ 159 | EntityID: string; 160 | 161 | /** 162 | * A collection of metadata information associated with the entity. The getEntityMetadata option of the request must be set 163 | * to true. Note, not all boundaries will return this metadata. 164 | */ 165 | EntityMetadata: IMetadata; 166 | 167 | /** Information about the name of the boundary location. */ 168 | Name: IName; 169 | 170 | /** A Polygon object that has been generated from the data in the Primitives property. */ 171 | Polygons: Polygon[]; 172 | 173 | /** An array of objects that contain the polygon information for the boundary. */ 174 | Primitives: IGeoDataPrimitive[]; 175 | } 176 | 177 | /** Represents the set of results returned by the GeoData API. */ 178 | export interface IGeoDataResultSet { 179 | /** Copyright information for the GeoData API. */ 180 | Copyright: string; 181 | 182 | /** The location provided in the query that generated this result. */ 183 | location: string |  Location; 184 | 185 | /** Results of the boundary data. */ 186 | results: IGeoDataResult[]; 187 | } 188 | 189 | /** 190 | * This is a static class that provides the ability to request polygons that describe the boundaries of a geographic entities, such as an AdminDivision1 191 | * (such as a state or province) or a Postcode1 (such as a zip code) that contain a given point (latitude and longitude) or address. This uses the GeoData 192 | * API in the Bing Spatial Data Services. 193 | * @requires The Microsoft.Maps.SpatialDataService module. 194 | */ 195 | export module GeoDataAPIManager { 196 | /** 197 | * Gets a boundary for the specified request. If the specified location value is a string, it will be geocoded and the coordinates of the result will 198 | * be used to find a boundary of the specified entityType that intersects with this coordinate. 199 | * @requires The Microsoft.Maps.SpatialDataService module. 200 | * @param locations The locations to retrieve boundaries for. If the specified location value is a string, it will be geocoded and the coordinates of 201 | * the result will be used to find a boundary of the specified entityType that intersects with this coordinate. 202 | * @param request The request options for retrieving a boundary. 203 | * @param credentials A bing maps key or a map instance which can be used to provide credentials to access the data source. Note that the map will need 204 | * to be loaded with a bing maps key that has access to the data source. 205 | * @param callback A callback function to return the results to. If an array of locations are specified the callback function will be triggered for each location in the array. 206 | * @param styles The polygon styling settings to apply to the boundary polygon. 207 | * @param errorCallback A callback function to trigger when an error occurs when searching for a boundary. 208 | */ 209 | export function getBoundary(locations: string | Location | (string | Location)[], 210 | request: IGetBoundaryRequestOptions, 211 | credentials: string | Map, 212 | callback: (results: IGeoDataResultSet) => void, 213 | styles?: IPolygonOptions, 214 | errorCallback?: (callbackState?: string | Location, networkStatus?: string) => void 215 | ): void; 216 | } 217 | 218 | ////////////////////////////////////////////// 219 | /// Query API 220 | ////////////////////////////////////////////// 221 | 222 | /** 223 | * An enumeration that defines how to compare the filters value against the corresponding property value. 224 | * @requires The Microsoft.Maps.SpatialDataService module. 225 | */ 226 | export enum FilterCompareOperator { 227 | /** Determines if a string value ends with a specified string value. */ 228 | endsWith, 229 | 230 | /** Determines if two values are equal. */ 231 | equals, 232 | 233 | /** Determines if a first value is greater than a second value. */ 234 | greaterThan, 235 | 236 | /** Determines if a first value is greater than or equal to a second value. */ 237 | greaterThanOrEqual, 238 | 239 | /** Determines if a value is within an array. */ 240 | isIn, 241 | 242 | /** Determines if a first value is less than a second value. */ 243 | lessThan, 244 | 245 | /** Determines if a first value is less than or equal a second value. */ 246 | lessThanOrEqual, 247 | 248 | /** Determines if a string value does not end with a specified string value. */ 249 | notEndsWith, 250 | 251 | /** Determines if two values are not equal. */ 252 | notEquals, 253 | 254 | /** Determines if a string value does not start with a specified string value. */ 255 | notStartsWith, 256 | 257 | /** Determines if a string value starts with a specified string value. */ 258 | startsWith 259 | } 260 | 261 | /** 262 | * An enumeration that defines how two or more filters are linked together. 263 | * @requires The Microsoft.Maps.SpatialDataService module. 264 | */ 265 | export enum FilterLogicalOperator { 266 | /** Connects two or more filters that both must be true. */ 267 | and, 268 | 269 | /** Connects two or more filters where one of them must be true. */ 270 | or 271 | } 272 | 273 | /** 274 | * A Fitler object that defines the logic behind a filter expression that can be executed against a JSON object or generate 275 | * a filter string that can be used with the Bing Spatial Data Services. 276 | */ 277 | export interface IFilter { 278 | /** 279 | * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. 280 | * @returns A boolean indicating if the specified object meets the requirements of the Filter. 281 | */ 282 | execute(object: any): boolean; 283 | 284 | /** 285 | * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. 286 | * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. 287 | */ 288 | toString(): string; 289 | } 290 | 291 | /** 292 | * The Fitler class defines the logic behind a filter expression that can be executed against a JSON object or generate 293 | * a filter string that can be used with the Bing Spatial Data Services. 294 | * @requires The Microsoft.Maps.SpatialDataService module. 295 | */ 296 | export class Filter implements IFilter { 297 | /** 298 | * @constructor 299 | * @requires The Microsoft.Maps.SpatialDataService module. 300 | * @param propertyName The name of the property in the object to test against. Can also provide child properties i.e. 'root.child'. 301 | * @param operator The operator to use when comparing the specified property to value to the provided value. 302 | * @param value A value to compare against. 303 | */ 304 | constructor(propertyName: string, operator: string | FilterCompareOperator, value: any); 305 | 306 | /** 307 | * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. 308 | * @returns A boolean indicating if the specified object meets the requirements of the Filter. 309 | */ 310 | public execute(object: any): boolean; 311 | 312 | /** 313 | * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. 314 | * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. 315 | */ 316 | public toString(): string; 317 | } 318 | 319 | /** 320 | * A class that groups two or more logical filters or filter groups together. It can be executed against a JSON or generate 321 | * a filter string that can be used with the Bing Spatial Data Services. 322 | * @requires The Microsoft.Maps.SpatialDataService module. 323 | */ 324 | export class FilterGroup implements IFilter { 325 | /** 326 | * @constructor 327 | * @requires The Microsoft.Maps.SpatialDataService module. 328 | * @param filters An array consisting of Filter or FilterGroup objects to combine. 329 | * @param operator The logical operator for combining the filters together. 330 | * @param not A boolean is the logical inverse should of the filter should be used. 331 | */ 332 | constructor(filters: IFilter[], operator: FilterLogicalOperator, not?: boolean) 333 | 334 | /** 335 | * Executes the filter logic against a JSON object and returns a boolean indicating if the object meets the requirements of the Filter. 336 | * @returns A boolean indicating if the specified object meets the requirements of the Filter. 337 | */ 338 | public execute(object: any): boolean; 339 | 340 | /** 341 | * Converts the filter logic into a string format that is compatible with the Bing Spatial Data Services. 342 | * @returns A filter string that is formatted such that it is compatible with the Bing Spatial Data Services. 343 | */ 344 | public toString(): string; 345 | } 346 | 347 | /** Options for find near route query API. */ 348 | export interface ISpatialFilterOptions { 349 | /** 350 | * One of the following values: 351 | * • nearby – Searches in a radius around a location. 352 | * • nearRoute – Searches for results that are within 1 mile of a route. 353 | * • intersects – Searches for results that intersect with the specified geometry. 354 | * Note: Note that the NavteqNA and NavteqEU data sources only support nearby queries. 355 | */ 356 | spatialFilterType: string; 357 | 358 | /** Location at which the filter should be applied (only for nearby filter). */ 359 | location?: string | Location; 360 | 361 | /** 362 | * Radius to use when performing a nearby search. The distance in kilometers and must be between 0.16 and 1000 kilometers 363 | * (only for nearby filter). 364 | */ 365 | radius?: number; 366 | 367 | /** Start location of the route (only for nearroute filter). */ 368 | start?: string | Location; 369 | 370 | /** End location of the route (only for nearroute filter). */ 371 | end?: string | Location; 372 | 373 | /** Intersection object. Can be a well known text string or a LocationRect object (only for intersects filter). */ 374 | intersects?: string | LocationRect | IPrimitive; 375 | } 376 | 377 | /** Options for find near route query API. */ 378 | export interface IFindNearRouteOptions extends ISpatialFilterOptions { 379 | /** 380 | * One of the following values: 381 | * • Driving [default] 382 | * • Walking 383 | */ 384 | travelMode?: string; 385 | 386 | /** 387 | * An integer value between 0 and 359 that represents degrees from north 388 | * where north is 0 degrees and the heading is specified clockwise from north. 389 | * For example, setting the heading of 270 degrees creates a route that initially heads west 390 | */ 391 | heading?: number; 392 | 393 | /** 394 | * An integer distance specified in meters. 395 | * Use this parameter to make sure that the moving vehicle has enough distance 396 | * to make the first turn 397 | */ 398 | distanceBeforeFirstTurn?: number; 399 | 400 | /** 401 | * A list of values that limit the use of highways and toll roads in the route. 402 | * Use one of the following values: 403 | * • highways - Avoids the use of highways in the route. 404 | * • tolls - Avoids the use of toll roads in the route. 405 | * • minimizeHighways - Minimizes (tries to avoid) the use of highways in the route. 406 | * • minimizeTolls - Minimizes (tries to avoid) the use of toll roads in the route. 407 | */ 408 | avoid?: string[]; 409 | 410 | /** 411 | * One of the following values: 412 | * • distance - The route is calculated to minimize the distance.Traffic information is not used. 413 | * • time[default] - The route is calculated to minimize the time.Traffic information is not used. 414 | * • timeWithTraffic - The route is calculated to minimize the time and uses current traffic information. 415 | */ 416 | optimize?: string; 417 | } 418 | 419 | /** Set of options that can be specified for query APIs. */ 420 | export interface IQueryAPIOptions { 421 | /** A queryurl containing the access id, data source name and the entity type name. */ 422 | queryUrl: string; 423 | 424 | /** Specifies a conditional expression for a list of properties and values. */ 425 | filter?: string | IFilter; 426 | 427 | /** Specifies whether or not to return a count of the results in the response. Default: false */ 428 | inlineCount?: boolean; 429 | 430 | /** Specifies to query the staged version of the data source instead of the published version. Default: false */ 431 | isStaging?: boolean; 432 | 433 | /** 434 | * Specifies one or more properties to use to sort the results of a query. 435 | * You can specify up to three (3) properties. Results are sorted in ascending order. 436 | * Note: You cannot use the latitude and longitude properties to sort results. You can use the elevation property. 437 | */ 438 | orderBy?: string[]; 439 | 440 | /** 441 | * Specifies the data source properties to return in the response. If the $select query option is not specified or 442 | * if it is set to "" ($select=), all data source properties are returned. Default: "*,_distance" 443 | */ 444 | select?: string[]; 445 | 446 | /** Specifies to not return a specified number of query results. */ 447 | skip?: number; 448 | 449 | /** Spatial filter options to apply. */ 450 | spatialFilter?: ISpatialFilterOptions | IFindNearRouteOptions; 451 | 452 | /** Specifies the maximum number of results to return in the query response. Default: 25 */ 453 | top?: number; 454 | } 455 | 456 | /** 457 | * This is a static class that provides that ability to query data sources that are hosted by the Bing Spatial Data Services using the Query API. 458 | * @requires The Microsoft.Maps.SpatialDataService module. 459 | */ 460 | export module QueryAPIManager { 461 | /** 462 | * Perform a search 463 | * @requires The Microsoft.Maps.SpatialDataService module. 464 | * @param queryOptions - Options for the query 465 | * @param credentials - Credentials for the query 466 | * @param callback - The function to call once the results are retrieved 467 | * @param styles - (Optional) Styles of the data that needs to be rendered on map 468 | * @param withoutLocationInfo - 469 | * @param errorCallback - 470 | */ 471 | export function search(queryOptions: IQueryAPIOptions, 472 | credentials: string | Map, 473 | callback: (data: IPrimitive[], inlineCount?: number) => void, 474 | styles?: IStylesOptions, 475 | errorCallback?: (networkStatus?: string, statusMessage?: string)=> void): void; 476 | } 477 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/SpatialMath.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | /** 28 | * This module provides a bunch of useful spatial math calculations. 29 | * @requires The Microsoft.Maps.SpatialMath module. 30 | */ 31 | declare module Microsoft.Maps.SpatialMath { 32 | 33 | /** 34 | * Distance Unit enumerator 35 | * @requires The Microsoft.Maps.SpatialMath module. 36 | **/ 37 | export enum DistanceUnits { 38 | /** A distance in meters */ 39 | Meters, 40 | 41 | /** A distance in kilometers */ 42 | Kilometers, 43 | 44 | /** A distance in miles */ 45 | Miles, 46 | 47 | /** A distance in Feet */ 48 | Feet, 49 | 50 | /** A distance in Yards */ 51 | Yards, 52 | 53 | /** A distance in Nautical Miles */ 54 | NauticalMiles 55 | } 56 | 57 | /** 58 | * Area units enumerator 59 | * @requires The Microsoft.Maps.SpatialMath module. 60 | **/ 61 | export enum AreaUnits { 62 | /** Area in square meters */ 63 | SquareMeters, 64 | 65 | /** Area in square kilometers */ 66 | SquareKilometers, 67 | 68 | /** Area in square miles */ 69 | SquareMiles, 70 | 71 | /** Area in square Feet */ 72 | SquareFeet, 73 | 74 | /** Area in square Yards */ 75 | SquareYards, 76 | 77 | /** Area in Acres */ 78 | Acres, 79 | 80 | /** Area in Hectares */ 81 | Hectares 82 | } 83 | 84 | ////////////////////////////////////////////// 85 | /// Core Calculations 86 | ////////////////////////////////////////////// 87 | 88 | /** 89 | * Converts an area from one area units to another. 90 | * @param area A number that represents an area to convert. 91 | * @param fromUnits The area units the original area is in. 92 | * @param toUnits The area units to convert to. 93 | * @returns An area in the new units. 94 | **/ 95 | export function convertArea(area: number, fromUnits: AreaUnits, toUnits: AreaUnits): number; 96 | 97 | /** 98 | * Converts a distance from one distance units to another. 99 | * @param distance A number that represents a distance to convert. 100 | * @param fromUnits The distance units the original distance is in. 101 | * @param toUnits The disired distance units to convert to. 102 | * @returns A distance in the new units. 103 | **/ 104 | export function convertDistance(distance: number, fromUnits: DistanceUnits, toUnits: DistanceUnits): number; 105 | 106 | /** 107 | * Calculates an array of locations that form a cardinal spline between the specified array of locations. 108 | * @param locations The array of locations to calculate the spline through. 109 | * @param tension A number that indicates the tightness of the curve. Can be any number, although a value between 0 and 1 is usually used. Default: 0.5 110 | * @param nodeSize Number of nodes to insert between each Location. Default: 15 111 | * @param close A boolean indicating if the spline should be a closed ring or not. Default: false 112 | * @returns An array of locations that form a cardinal spline between the specified array of locations. 113 | */ 114 | export function getCardinalSpline(locations: Location[], tension ?: number, nodeSize ?: number, close ?: boolean): Location[]; 115 | 116 | /** 117 | * Calculates a destination Location based on a starting Location, a heading, a distance, and a distance unit type. 118 | * @param origin Location that the destination is relative to. 119 | * @param bearing A heading angle between 0 - 360 degrees. 0 - North, 90 - East, 180 - South, 270 - West. 120 | * @param distance Distance that destination is away. 121 | * @param units Unit of distance measurement. Default is Meters. 122 | * @returns A Location that is the specified distance away from the origin. 123 | **/ 124 | export function getDestination(origin: Location, bearing: number, distance: number, units?: DistanceUnits): Location; 125 | 126 | /** 127 | * Calculate the distance between two Location objects on the surface of the earth using the Haversine formula. 128 | * @param origin First Location to calculate distance between. 129 | * @param destination Second Location to calculate distance between. 130 | * @param units Unit of distance measurement. Default is Meters. 131 | * @param highAccuracy When set enabled, will use the slower but more accurate Vincenty formula for calculating distances, rather than the Haversine formula. 132 | * @returns The shortest distance between two Locations in the specifed units. 133 | **/ 134 | export function getDistanceTo(origin: Location, destination: Location, units?: DistanceUnits, highAccuracy?: boolean): number; 135 | 136 | /** 137 | * Retrieves the radius of the earth in a specific distance unit for WGS84. 138 | * @param units Unit of distance measurement. Default: Meters 139 | * @returns A number that represents the radius of the earth in a specific distance unit. 140 | **/ 141 | export function getEarthRadius(units?: DistanceUnits): number; 142 | 143 | /** 144 | * Takes an array of Locations objects and fills in the space between them with accurately positioned Locations to form an approximated Geodesic path. 145 | * @param path Array of Location objects that form a path to fill in. 146 | * @param nodeSize Number of nodes to insert between each Location. Default: 15 147 | * @returns An array of Location objects that form a geodesic paths. 148 | **/ 149 | export function getGeodesicPath(path: Location[], nodeSize?: number): Location[]; 150 | 151 | /** 152 | * Calculates the heading from one Location object to another. 153 | * @param origin Point of origin. 154 | * @param destination Destination to calculate relative heading to. 155 | * @returns A heading in degrees between 0 and 360. 0 degrees points due North. 156 | **/ 157 | export function getHeading(origin: Location, destination: Location): number; 158 | 159 | /** 160 | * Calculates the distance between all Location objects in an array. 161 | * @param path The array of Location objects that make up the path to calculate the length of. 162 | * @param units Unit of distance measurement. Default: Meters 163 | * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. 164 | * @returns The distance between all Locations in between all Location objects in an array on the surface of a earth in the specifed units. 165 | **/ 166 | export function getLengthOfPath(path: Location[], units?: DistanceUnits, highAccuracy?: boolean): number; 167 | 168 | /** 169 | * Calculates the Location object on a path that is a specified distance away from the start of the path. If the specified distance is longer 170 | * than the length of the path, the last Location of the path will be returned. 171 | * @param path A polyline or array of Location coordinates that form a path. 172 | * @param distance The distance along the path (from the start) to calculate the location for. 173 | * @param units Unit of distance measurement. Default is Meters. 174 | * @returns A Location object that is the specified distance away from the start of the path when following the path. 175 | **/ 176 | export function getLocationAlongPath(path: Polyline | Location[], distance: number, units?: DistanceUnits): Location; 177 | 178 | /** 179 | * Calculates an array of Location objects that are an equal distance away from a central point to create a regular polygon. 180 | * @param origin Center of the regular polygon. 181 | * @param radius Radius of the regular polygon. 182 | * @param numberOfPoints Number of points the polygon should have. 183 | * @param units Unit of distance measurement for radius. Default is Meters. 184 | * @param offset An offset to rotate the polygon clockwise in degrees. When 0 the first Location will align with North. 185 | * @returns An array of Location objects that form a regular polygon. 186 | **/ 187 | export function getRegularPolygon(origin: Location, radius: number, numberOfPoints: number, units?: DistanceUnits, offset?: number): Location[]; 188 | 189 | /** 190 | * Calculates a Location object that is a fractional distance between two Location objects. 191 | * @param origin First Location to calculate mid-point between. 192 | * @param destination Second Location to calculate mid-point between. 193 | * @param fraction The fractional parameter to calculate a mid-point for. Default 0.5. 194 | * @returns A Location that lies a fraction of the distance between two Location objects, relative to the first Location object. 195 | **/ 196 | export function interpolate(origin: Location, destination: Location, fraction?: number): Location; 197 | 198 | /** 199 | * Takes a LocationRect and converts it to a polygon. 200 | * @param bounds The LocationRect to convert to a Polygon. 201 | * @returns A polygon representation of the LocationRect. 202 | **/ 203 | export function locationRectToPolygon(bounds: LocationRect): Polygon; 204 | 205 | /** 206 | * Takes a Location object and converts it into a Degree Minute Seconds string in the format. For example: 40° 26′ 46″ N 79° 58′ 56″ W 207 | * @param loc The Location object to convert into a Degree Minute Seconds string. 208 | * @returns A string in Degree Minute Seconds format or null if invalid Location object is provided. 209 | */ 210 | export function toDegMinSec(loc: Location): string; 211 | 212 | /** 213 | * Tries to parse the given string that is in Degree Minute Seconds format. For Example: 35° 26′ 31″ E or 40° 26′ 46″ N 79° 58′ 56″ W 214 | * @param input A string in Degree Minute Seconds format to parse. 215 | * @returns Returns a decimal degree value if only a single angle is provided. If two angles provided in the string, then a 216 | * Location object is returned. If string is in an invalid format, null is returned. 217 | */ 218 | export function tryParseDegMinSec(input: string): number | Location; 219 | } 220 | 221 | 222 | ////////////////////////////////////////////// 223 | /// Tile Calculations 224 | ////////////////////////////////////////////// 225 | 226 | /** 227 | * A colleciton of mathematical algorithms based on the tile pyramid used by Bign Maps. 228 | * @requires The Microsoft.Maps.SpatialMath module. 229 | */ 230 | declare module Microsoft.Maps.SpatialMath.Tiles { 231 | //Based on https://msdn.microsoft.com/en-us/library/bb259689.aspx 232 | 233 | /** 234 | * Calculates the full width of the map in pixels at a specific zoom level from -180 degrees to 180 degrees. 235 | * @param zoom Zoom level to calculate width at. 236 | * @param tileWidth Width of tile. 237 | * @returns Width of map in pixels. 238 | **/ 239 | export function mapSize(zoom: number): number; 240 | 241 | /** 242 | * Calculates the Ground resolution at a specific degree of latitude in the specified units per pixel. 243 | * @param latitude Degree of latitude to calculate resolution at. 244 | * @param zoom Zoom level to calculate resolution at. 245 | * @param units Distance unit type to calculate resolution in. 246 | * @returns Ground resolution in distance unit per pixels. 247 | **/ 248 | export function groundResolution(latitude: number, zoom: number, units?: SpatialMath.DistanceUnits): number; 249 | 250 | /** 251 | * Converts a Pixel coordinate into a Geospatial Location at a specified zoom level. 252 | * Global Pixel coordinates are relative to the top left corner of the map (90, -180) 253 | * @param point Pixel coordinate. 254 | * @param zoom Zoom level. 255 | * @returns A Location that is at the specified pixel location at a specified zoom level. 256 | **/ 257 | export function globalPixelToLocation(point: Point, zoom: number): Location; 258 | 259 | /** 260 | * Converts a point from latitude/longitude WGS-84 Location (in degrees) 261 | * into pixel XY coordinates at a specified level of detail. 262 | * @param loc Location to convert to a global pixel. 263 | * @param zoom Level of detail, from 1 (lowest detail) to 23 (highest detail). 264 | * @returns Point object containing the the global pixel location of a Location. 265 | **/ 266 | export function locationToGlobalPixel(loc: Location, zoom: number): Point; 267 | 268 | /** 269 | * Calculates the PyramidTileId that a global pixel intersects with at a specific zoom level. 270 | * @param pixel The pixel coordinate to calculate the tile for. 271 | * @param zoom The zoom level to calculate the tile for. 272 | * @returns A PyramidTileId that a global pixel intersects with at a specific zoom level. 273 | **/ 274 | export function globalPixelToTile(pixel: Point, zoom: number): PyramidTileId; 275 | 276 | /** 277 | * Converts a PyramidTileId into a global pixel coordinates of the upper-left pixel of the specified tile. 278 | * @param tile A PyramidTileId to calculate the upper-left pixel for. 279 | * @returns Global pixel coordinate of the top left corner of a tile. 280 | **/ 281 | export function tileToGlobalPixel(tile: PyramidTileId): Point; 282 | 283 | /** 284 | * Calculates the PyramidTileId that a Location object intersects with at a specific zoom level. 285 | * @param loc The location to calulate the tile for. 286 | * @param zoom The zoom level to use to calculate the tile. 287 | * @returns A PyramidTileId that a Location object intersects with at a specific zoom level. 288 | **/ 289 | export function locationToTile(loc: Location, zoom: number): PyramidTileId; 290 | 291 | /** 292 | * Calculates all the PyramidTileId's that are within a LocationRect at a specific zoom level. 293 | * @param bounds A LocationRect to search for tiles in. 294 | * @param zoom The zoom level to calculate tiles for. 295 | * @returns A list of PyramidTileId's that are within the specified LocationRect and zoom level. 296 | **/ 297 | export function getTilesInBounds(bounds: LocationRect, zoom: number): PyramidTileId[]; 298 | 299 | /** 300 | * Calculates the LocationRect (bounding box) of a PyramidTileId. 301 | * @param tile A PyramidTileId to calculate the LocationRect of. 302 | * @returns The bounding box of a tile. 303 | **/ 304 | export function tileToLocationRect(tile: PyramidTileId): LocationRect; 305 | } 306 | 307 | 308 | ////////////////////////////////////////////// 309 | /// Geometry Calculations 310 | ////////////////////////////////////////////// 311 | 312 | /** 313 | * A colleciton of geometry calculations that can be performed against Bing Maps shapes. 314 | * @requires The Microsoft.Maps.SpatialMath module. 315 | */ 316 | declare module Microsoft.Maps.SpatialMath.Geometry { 317 | 318 | /** Defines how the end of a line should be buffered. */ 319 | export enum BufferEndCap { 320 | /** Adds a rounded end to a buffered line. */ 321 | Round, 322 | 323 | /** Adds a flat end to a buffered line that touches the end of the line. */ 324 | Flat, 325 | 326 | /** Adds a square end to a buffered line that has a buffer area at the end of the line. */ 327 | Square 328 | } 329 | 330 | /** 331 | * Calculates the area of a shape. 332 | * @param shape The shape to calculate the area of. 333 | * @param areaUnits The unit of measurement to calculate the area in. 334 | * @returns The area of a shape in the specified unit of measurement. 335 | */ 336 | export function area(shape: IPrimitive | IPrimitive[], areaUnits?: AreaUnits): number; 337 | 338 | /** 339 | * Calculates a bounding box that encloses a set of shapes and/or locations. 340 | * @param shapes The shape(s) to calculate the bounding box for. 341 | * @returns A location rect that encloses the shapes and/or locations. 342 | */ 343 | export function bounds(shapes: Location | IPrimitive | (Location | IPrimitive)[]): LocationRect; 344 | 345 | /** 346 | * Calcuates a shape with an updated boundary that has been inflated/deflated by a speicifed distance. 347 | * @param shape The shape to buffer. 348 | * @param distance The distance to buffer the shape by. 349 | * @param units The distance units to buffer the shape by. 350 | * @param endCapType The type of end cap to use for the joints of the buffer, default value is round. 351 | * @param options A set of polygon options to apply to the generated shape. 352 | * @returns A buffered version of the shape. 353 | */ 354 | export function buffer(shape: Location | IPrimitive | (Location | IPrimitive)[], distance: number, units?: DistanceUnits, endCapType?: BufferEndCap, options?: IPolygonOptions): IPrimitive | IPrimitive[]; 355 | 356 | /** 357 | * Calculates the center of a shape. 358 | * @param shape The shape to calculate the center of. 359 | * @returns The center of the specified shape. 360 | */ 361 | export function centroid(shape: IPrimitive | IPrimitive[]): Location; 362 | 363 | /** 364 | * Calculates an approximate concave hull that best fits the data. 365 | * A concave hull is a shape that represents that a possible concave geometry that encloses all shapes in the specified data set. 366 | * If a single unique Location is in the data set, a Pushpin is returned. If only two unique Locations are provided, or if all Locations form a line, a Polyline is returned. 367 | * If 3 or more unique Locations are in the data set a Polygon, or array of Polygons will be returned. 368 | * @param shapes Shape(s) whose Location(s) or Location(s) are to be used to generate a concave hull. 369 | * @param allowMultiPolygons A boolean indicating if the resulting concave hull can be a MultiPolygon. Default: false 370 | * @param allowHoles A boolean indicating if the polygons in the resulting concave hull can have holes in them. Default: false 371 | * @param options A set of polygon options to apply to the generated shape. 372 | * @returns An approximate concave hull that best fits the data. 373 | * If a single unique Location is in the data set, a Pushpin is returned. If only two unique Locations are provided, or if all Locations form a line, a Polyline is returned. 374 | * If 3 or more unique Locations are in the data set a Polygon, or array of Polygons will be returned. 375 | */ 376 | export function concaveHull(shapes: Location | IPrimitive | (Location | IPrimitive)[], allowMultiPolygons?: boolean, allowHoles?: boolean, options?: IPolygonOptions): IPrimitive | IPrimitive[]; 377 | 378 | /** 379 | * Given two shapes, determines if the first one contains the second one 380 | * (or, the second shape is a subset of the first shape) or not. 381 | * @param shapeA The first shape to test against the second. 382 | * @param shapeB The second shape to test against the first. 383 | * @returns A boolean indicating if the first shape contains the second shape. 384 | */ 385 | export function contains(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): boolean; 386 | 387 | /** 388 | * Calculates a convex hull. A convex hull is a shape that represents that minimum convex geometry that encloses all shapes in the specified data set. 389 | * @param shapes Shape(s) whose Location(s) or Location(s) are to be used to generate a convex hull. 390 | * @param options A set of polygon options to apply to the generated shape. 391 | * @returns An array of locations that form a convex hull that encloses all locations of the shapes provided in an array. 392 | */ 393 | export function convexHull(shapes: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolygonOptions): IPrimitive | IPrimitive[]; 394 | 395 | /** 396 | * Creates Delaunay Triangles from the Location objects of the provided shapes. 397 | * @param shapes Location(s) of shape(s) or Location(s) to generate a Delaunay Triangles from. 398 | * @param options A set of polyline or polygon options to apply to the generated shape. 399 | * @returns An array of shapes that form the polygon triangles of the delaunay triangles. 400 | */ 401 | export function delaunayTriangles(shapes: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolygonOptions): Polygon[]; 402 | 403 | /** 404 | * Returns an object that represents area of an initial shape subtracted by the overlapping area of a second shape. 405 | * @param shapeA The first shape. 406 | * @param shapeB The second shape to subtract from the first. 407 | * @returns A set of shapes that represent the area of the first shape that is not overlapped by the second shape. 408 | */ 409 | export function difference(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; 410 | 411 | /** 412 | * Calculates the approximate shortest distance between any two shapes. 413 | * @param shapeA The first shape to calculate the distance from. 414 | * @param shapeB The second shape to calculate the distance to. 415 | * @param units Unit of distance measurement. Default: Meters 416 | * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. 417 | * @returns The shorested distance between the shapes in the specified units. 418 | */ 419 | export function distance(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[], units?: DistanceUnits, highAccuracy?: boolean): number; 420 | 421 | /** 422 | * Returns an object that represents the area where two shapes intersect. 423 | * @param shapeA The first shape. 424 | * @param shapeB The second shape. 425 | * @returns A set of shapes that represents the area where two shapes intersect. 426 | */ 427 | export function intersection(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; 428 | 429 | /** 430 | * Determines if two shapes intersect or not. 431 | * @param shapeA The first shape to test against the second. 432 | * @param shapeB The second shape to test against the first. 433 | * @returns A boolean indicating if the two shapes intersect. 434 | */ 435 | export function intersects(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): boolean; 436 | 437 | /** 438 | * Tests to see if the shape is valid and meets the requirements of an SQL Geography type and other OGC compliant systems. Polylines & Polygons can't be self intersecting. For Polygons, 439 | * coordinates in an exterior rings have a counter-clockwise orientation, while holes have a clockwise orientation. 440 | * @param shape The shape to test for validity. 441 | * @returns Returns a boolean indicting if the specified shape(s) is valid or not. 442 | */ 443 | export function isValid(shape: IPrimitive | IPrimitive[]): boolean; 444 | 445 | /** 446 | * Calculates the distance between all Locations in a shape. If the shape is a polygon, the length of the perimeter of all rings is calculated. 447 | * @param shape The shape to calculate the length of. 448 | * @param units Unit of distance measurement. Default: Meters 449 | * @param highAccuracy If set to true, uses the more accurate Vincenty algorithm for calcuating distances. Otherwise the faster Haversine formula is used. 450 | * @returns The distance between all Locations in a polyline or the perimeter of a ploygon on the surface of a earth in the specifed units. 451 | */ 452 | export function calculateLength(shape: IPrimitive | IPrimitive[], units ?: DistanceUnits, highAccuracy ?: boolean): number; 453 | 454 | /** 455 | * Takes a shape and returns a copy of it that meets the requirements of an SQL Geography type and other OGC compliant systems. Polylines & Polygons can't be self intersecting. For Polygons, 456 | * coordinates in an exterior rings have a counter-clockwise orientation, while holes have a clockwise orientation. 457 | * @param shape The shape to make valid. 458 | * @returns Valiated version of the provided shape. May be a different shape type than what was provided. i.e. A polygon may be broken up into an array of polygons (MultiPolygon). 459 | */ 460 | export function makeValid(shape: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; 461 | 462 | /** 463 | * Calculates the nearest Location objects between to shapes that lie on the shapes. 464 | * If the shapes do not overlap, this calculates a location on each shape that is closest to the other shape. 465 | * If the shapes overlap, a location that is within the intersection area of the shapes will be added twice to an array, once for each shape, and returned. 466 | * @param shapeA The first shape. 467 | * @param shapeB The second shape. 468 | * @returns An array of two Location objects that represent the nearest points between two shapes. 469 | * The Location objects are in the same order as the input shapes. 470 | * Returns null if nearest points were unable to be computed. 471 | */ 472 | export function nearestLocations(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[]): Location[]; 473 | 474 | /** 475 | * Reduces the resolution of a shape using the Douglas-Peucker algorithm. 476 | * @param shape The shape to reduce the resolution of. 477 | * @param tolerance A tolerance distance in meters used by the reduction algorithms. 478 | * @returns A version of the specified shape that has been reduced. 479 | */ 480 | export function reduce(shape: IPrimitive | IPrimitive[], tolerance: number): IPrimitive | IPrimitive[]; 481 | 482 | /** 483 | * Rotates a shape around a given Location for the specified angle of rotation. If an origin is not provided, the centroid of the shape is used. 484 | * @param shape The shape to be rotated. 485 | * @param angle The amount to rotate the shape in degrees. 486 | * @param origin The location to rotate the shape around. Defaults to the centroid of the shape. 487 | */ 488 | export function rotate(shape: IPrimitive | IPrimitive[], angle: number, origin?: Location): void; 489 | 490 | /** 491 | * Calculates the shortest path that between two shapes and returns a Polyline. 492 | * @param shapeA The first shape. 493 | * @param shapeB The second shape. 494 | * @param options A set of polyline options to apply to the generated polyline. 495 | * @returns A polyline that represents the shortest path between two shapes. 496 | */ 497 | export function shortestLineTo(shapeA: Location | IPrimitive | (Location | IPrimitive)[], shapeB: Location | IPrimitive | (Location | IPrimitive)[], options?: IPolylineOptions): Polyline; 498 | 499 | /** 500 | * Snaps the locations of one shape that are within the specified tolerance distance away from another shape. 501 | * @param locs The locations to snap to the shape. 502 | * @param shape The shape to snap the locations to. 503 | * @param tolerance A maximum distance (in the specified units) that the snapped location can be from the input location. Default: Infinity 504 | * @param toleranceUnits The distance units of the tolerance value. Default: Meters 505 | * @returns A snapped location if only one location is provided, otherwise returns an array of snapped locations. 506 | */ 507 | export function snapLocationsToShape(locs: Location | Location[], shape: IPrimitive | IPrimitive[], tolerance?: number, toleranceUnits?: DistanceUnits): Location | Location[]; 508 | 509 | /** 510 | * Snaps the locations of one shape that are within the specified tolerance distance away from another shape. 511 | * @param shapeToSnap The shape to snap the locations of. 512 | * @param shape The shape to snap the locations to. 513 | * @param tolerance A maximum distance (in the specified units) that the snapped location can be from the input location. Default: Infinity 514 | * @param toleranceUnits The distance units of the tolerance value. Default: Meters 515 | */ 516 | export function snapShapeToShape(shapeToSnap: IPrimitive | IPrimitive[], shape: IPrimitive | IPrimitive[], tolerance?: number, toleranceUnits?: DistanceUnits): void; 517 | 518 | /** 519 | * Returns an object that represents all points that are either in one shape instance or another, but not those points that lie in both instances. 520 | * "Sym" stands for Symmetric. symDifference is an OGC standard name for this calculation used in most spatial math libraries, including SQL. 521 | * @param shapeA The first shape. 522 | * @param shapeB The second shape. 523 | * @returns A shape that represents the symetric difference between two shapes. 524 | */ 525 | export function symDifference(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; 526 | 527 | /** 528 | * Returns an object that represents the union of two shapes. If shapes don't overlap, an array of each individual shapes will be returned. 529 | * @param shapeA The first shape. 530 | * @param shapeB The second shape. 531 | * @returns A shape that represents the union of two shapes. 532 | */ 533 | export function union(shapeA: IPrimitive | IPrimitive[], shapeB: IPrimitive | IPrimitive[]): IPrimitive | IPrimitive[]; 534 | 535 | /** 536 | * Performs a union operation on a set of shapes. 537 | * If a shape doesn't overlap with the rest, the returned result will be an array of shapes containing this shape and the union of the rest. 538 | * @param shapes An array of shapes to union together. 539 | * @returns A shape that represents the union of all specified shapes. 540 | */ 541 | export function unionAggregate(shapes: IPrimitive[]): IPrimitive | IPrimitive[]; 542 | 543 | /** 544 | * Creates a Voronoi diagram from the Location objects of the provided shapes. The diagram is returned as an array of Polygons. 545 | * If a clip region is specified, the diagram will be clipped accordingly. 546 | * @param shapes Location(s) of shape(s) or Location(s) to generate a Voronoi diagram. 547 | * @param clipRegion A region to clip the voronoi diagram to. 548 | * @param options A set of polygon options to apply to the generated shape. 549 | * @returns An array of polygons that form a Voronoi diagram. 550 | */ 551 | export function voronoiDiagram(shapes: Location | IPrimitive | (Location | IPrimitive)[], clipRegion?: LocationRect | Polygon, options?: IPolygonOptions): Polygon[]; 552 | } -------------------------------------------------------------------------------- /types/MicrosoftMaps/Modules/Directions.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2017 Microsoft Corporation. All rights reserved. 3 | * 4 | * This code is licensed under the MIT License (MIT). 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | * of the Software, and to permit persons to whom the Software is furnished to do 11 | * so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /// 26 | 27 | declare module Microsoft.Maps.Directions { 28 | ///////////////////////////////////// 29 | /// Enumerations 30 | //////////////////////////////////// 31 | 32 | /** Distance units for calculating the directions in. */ 33 | export enum DistanceUnit { 34 | 35 | /** A distance in Kilometers. */ 36 | km, 37 | 38 | /** A distance in Miles. */ 39 | miles 40 | } 41 | 42 | /** Defines the type of route to calculate. */ 43 | export enum RouteMode { 44 | /** Driving directions are calculated. */ 45 | driving, 46 | 47 | /** Transit directions are calculated. */ 48 | transit, 49 | 50 | /** Driving directions using truck attributes are calculationed. */ 51 | truck, 52 | 53 | /** Walking directions are calculated. */ 54 | walking 55 | } 56 | 57 | /** Defines features to avoid when calculating the route. */ 58 | export enum RouteAvoidance { 59 | /** Calculate the best route using any travel option available. */ 60 | none = 0, 61 | 62 | /** Reduce the use of limited access highways when calculating the route. */ 63 | minimizeHighways = 1, 64 | 65 | /** Reduce the use of roads with tolls when calculating the route. */ 66 | minimizeToll = 2, 67 | 68 | /** Avoid using limited access highways when calculating the route. */ 69 | avoidHighways = 4, 70 | 71 | /** Avoid using roads with tolls when calculating the route. */ 72 | avoidToll = 8, 73 | 74 | /** Avoid using express trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ 75 | avoidExpressTrain = 16, 76 | 77 | /** Avoid using airlines when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ 78 | avoidAirline = 32, 79 | 80 | /** Avoid using bullet trains when calculating the route. This option only affects routes with a transitRouteMode that have the culture set to ja-jp. */ 81 | avoidBulletTrain = 64 82 | } 83 | 84 | /** Response codes for a route calculation request. */ 85 | export enum RouteResponseCode { 86 | /** The route was successfully calculated. */ 87 | success = 0, 88 | 89 | /** An unknown error has occurred. */ 90 | unknownError = 1, 91 | 92 | /** A nearby road cannot be found for one or more of the route waypoints. */ 93 | cannotFindNearbyRoad = 2, 94 | 95 | /** 96 | * The distance between two route waypoints, or the total length of the route exceeds the limit of the route mode. 97 | * Modify the waypoint locations so that they are closer together. 98 | */ 99 | tooFar = 3, 100 | 101 | /** 102 | * A route cannot be calculated for the specified waypoints. For example, this code is returned when a route between 103 | * “Seattle, WA” and “Honolulu, HI” is requested. 104 | */ 105 | noSolution = 4, 106 | 107 | /** There is no route data for the specified waypoints. */ 108 | dataSourceNotFound = 5, 109 | 110 | /** There are no transit options available for the specified time. */ 111 | noAvailableTransitTrip = 7, 112 | 113 | /** The transit stops are so close that walking is always a better option. */ 114 | transitStopsTooClose = 8, 115 | 116 | /** The transit stops are so close that walking is a better option. */ 117 | walkingBestAlternative = 9, 118 | 119 | /** 120 | * There is no transit data available for the route or for one or more of the specified waypoints, 121 | * or the waypoints are in different transit areas that do not overlap. 122 | */ 123 | outOfTransitBounds = 10, 124 | 125 | /** The directions calculation request has timed out. */ 126 | timeOut = 11, 127 | 128 | /** 129 | * One or more waypoints need to be disambiguated. This error does not occur if the 130 | * autoDisplayDisambiguation directions render option is set to true. 131 | */ 132 | waypointDisambiguation = 12, 133 | 134 | /** One or more waypoints do not have an address or location specified. */ 135 | hasEmptyWaypoint = 13, 136 | 137 | /** The maximum number of waypoints, which is 25, has been exceeded. */ 138 | exceedMaxWaypointLimit = 14, 139 | 140 | /** At least two waypoints are required to calculate a route. */ 141 | atleastTwoWaypointRequired = 15, 142 | 143 | /** The first or last waypoint is a via point, which is not allowed. */ 144 | firstOrLastStoppointIsVia = 16, 145 | 146 | /** The search service failed to return results. */ 147 | searchServiceFailed = 17, 148 | 149 | /** The credentials passed to the Directions module are invalid. */ 150 | invalidCredentials = 18 151 | } 152 | 153 | /** Defines optimization options for calculating directions. */ 154 | export enum RouteOptimization { 155 | /** Calculate a route the shortest time. */ 156 | shortestTime = 0, 157 | 158 | /** Calculate a route with the shortest distance. */ 159 | shortestDistance = 1, 160 | 161 | /** The route is calculated to minimize the time and uses current traffic information. */ 162 | timeWithTraffic = 2, 163 | 164 | /** The route is calculated to minimize the time and avoid road closures. Traffic information is not used in the calculation. */ 165 | timeAvoidClosure = 3, 166 | 167 | /** Minimize the cost when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ 168 | minimizeMoney = 4, 169 | 170 | /** Minimize transit transfers when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ 171 | minimizeTransfers = 5, 172 | 173 | /** Minimize the amount of walking when calculating directions. This option only affects routes with a transitRouteMode that have the culture set to ja-jp.*/ 174 | minimizeWalking = 6 175 | } 176 | 177 | /** An enumeration that specifies the releance of a dateTime when calculating a route. */ 178 | export enum TimeType { 179 | /** The dateTime parameter contains the desired arrival time for a transit request. */ 180 | arrival, 181 | 182 | /** The dateTime parameter contains the desired departure time for a transit request. */ 183 | departure, 184 | 185 | /** The dateTime parameter should be ignored and the first available transit taken. */ 186 | firstAvailable, 187 | 188 | /** The dateTime parameter contains the latest departure time available for a transit request. */ 189 | lastAvailable 190 | } 191 | 192 | ///////////////////////////////////// 193 | /// Interfaces 194 | //////////////////////////////////// 195 | 196 | /** Contains the arguments for directions events. */ 197 | export interface IDirectionsEventArgs { 198 | /** The calculated route (or routes, if the route mode is transit). */ 199 | route: IRoute[]; 200 | 201 | /** The route summary (or summaries) of the route(s) defined in the route property. */ 202 | routeSummary: IRouteSummary[]; 203 | } 204 | 205 | /** Contains arguments for directions error events. */ 206 | export interface IDirectionsErrorEventArgs { 207 | /** The code which identifies the error that occurred. */ 208 | responseCode: RouteResponseCode; 209 | 210 | /** The error message. */ 211 | message: string; 212 | } 213 | 214 | /** Represents one direction in a set of route directions. */ 215 | export interface IDirectionsStep { 216 | /** The child direction items for this directions step. */ 217 | childItineraryItems: IDirectionsStep[]; 218 | 219 | /** The location of the start of the direction. */ 220 | coordinate: Location; 221 | 222 | /** The total distance of the step in the unit specified in the distanceUnit property of the DirectionsRequestOptions. */ 223 | distance: string; 224 | 225 | /** The total time, in seconds, of the direction step. */ 226 | durationInSeconds: number; 227 | 228 | /** The HTML formatted route instruction associated with the step. */ 229 | formattedText: string; 230 | 231 | /** A boolean indicating whether the maneuver image is a road shield image. */ 232 | isImageRoadShield: boolean; 233 | 234 | /** The type of maneuver being performed. */ 235 | maneuver: string; 236 | 237 | /** An array of strings, where each string is a hint to help determine when to move to the next direction step. Not all direction steps have hints. */ 238 | postIntersectionHints: string[]; 239 | 240 | /** An array of strings, where each string is a hint to help determine when you have arrived at this direction step. Not all direction steps have hints. */ 241 | preIntersectionHints: string[]; 242 | 243 | /** The name of the transit stop where this step originates. */ 244 | startStopName: string; 245 | 246 | /** The transit line associated with this step. */ 247 | transitLine: ITransitLine; 248 | 249 | /** The URL of the image to use for transit direction steps. */ 250 | transitStepIcon: string; 251 | 252 | /** The ID of the transit stop. */ 253 | transitStopId: string; 254 | 255 | /** The name of the transit line end. */ 256 | transitTerminus: string; 257 | 258 | /** An array of route warnings associated with this step. */ 259 | warnings: IDirectionsStepWarning[]; 260 | } 261 | 262 | /** Represents a route direction warning, such as a traffic congestion warning. */ 263 | export interface IDirectionsStepWarning { 264 | /** Where the warning starts. */ 265 | origin: string; 266 | 267 | /** The severity of the warning. Values can be: Low Impact, Minor, Moderate, Serious or None. */ 268 | severity: string; 269 | 270 | /** The warning text. */ 271 | text: string; 272 | 273 | /** Where the warning ends. */ 274 | to: string; 275 | 276 | /** The type of warning. A list of Warning type values can be found here: https://msdn.microsoft.com/en-us/library/hh441731.aspx */ 277 | warningType: string; 278 | } 279 | 280 | /** Represents a route. */ 281 | export interface IRoute { 282 | /** The legs of the route. Each route leg represents the route between two waypoints. */ 283 | routeLegs: IRouteLeg[]; 284 | 285 | /** An array of locations that makes up the path of the route. */ 286 | routePath: Location[]; 287 | } 288 | 289 | /** Represents a leg of a route. A route leg is the part of the route between two stop waypoints. */ 290 | export interface IRouteLeg { 291 | /** The end time of the route leg. This property only applies when the routeMode of the DirectionsRequestOptions is set to transit. */ 292 | endTime: Date; 293 | 294 | /** The location of the last waypoint of this leg. */ 295 | endWaypointLocation: Location; 296 | 297 | /** The directions steps associated with this route leg. */ 298 | itineraryItems: IDirectionsStep[]; 299 | 300 | /** The index of the route to which this route leg belongs. */ 301 | originalRouteIndex: number; 302 | 303 | /** The start time of the route leg. This property only applies when the routeMode of the DirectionsRequestOptions is set to transit. */ 304 | startTime: Date; 305 | 306 | /** The location of the first waypoint of this route leg. */ 307 | startWaypointLocation: Location; 308 | 309 | /** The sub legs of this route leg. A sub leg of a route is the part of the route between a stop point and a via point or between two via points.*/ 310 | subLegs: IRouteSubLeg[]; 311 | 312 | /** The summary which describes this route leg. */ 313 | summary: IRouteSummary; 314 | } 315 | 316 | /** Represents a route sub leg. A route sub leg is the part of the route between a stop point and a via point or between two via points. */ 317 | export interface IRouteSubLeg { 318 | /** The location of the last waypoint of the sub leg. */ 319 | actualEnd: Location; 320 | 321 | /** The location of the first waypoint of the sub leg. */ 322 | actualStart: Location; 323 | 324 | /** The description of the last waypoint of the sub leg. */ 325 | endDescription: string; 326 | 327 | /** The description of the first waypoint of the sub leg. */ 328 | startDescription: string; 329 | } 330 | 331 | /** Represents a route summary. */ 332 | export interface IRouteSummary { 333 | /** The total travel distance of the route */ 334 | distance: number; 335 | 336 | /** The cost of the route. This property is only returned if the routeMode of the IDirectionsRequestOptions is set to transit and the map culture is set to ja-jp. */ 337 | monetaryCost: number; 338 | 339 | /** The location of the northeast corner of bounding box that defines the best map view of the route. */ 340 | northEast: Location; 341 | 342 | /** The location of the southwest corner of bounding box that defines the best map view of the route. */ 343 | southWest: Location; 344 | 345 | /** The total travel time, in seconds, for the route. */ 346 | time: number; 347 | 348 | /** 349 | * The total travel time, in seconds, taking into account traffic delays, for the route. 350 | * This property is 0 if the avoidTraffic property of the IDirectionsRequestOptions is set to false. 351 | */ 352 | timeWithTraffic: number; 353 | } 354 | 355 | /** Contains information about a transit line. */ 356 | export interface ITransitLine { 357 | /** The short name for the transit line. */ 358 | abbreviatedName: string; 359 | 360 | /** The ID of the agency that owns the transit line. */ 361 | agencyId: number; 362 | 363 | /** The name of the agency that owns the transit line. */ 364 | agencyName: string; 365 | 366 | /** The URL of the website of the agency that owns the transit line. */ 367 | agencyUrl: string; 368 | 369 | /** Phone number for the transit agency. */ 370 | phoneNumber: string; 371 | 372 | /** Information about the provider of this transit line data. */ 373 | providerInfo: string; 374 | 375 | /** The uri for the transit agencies website. */ 376 | uri: string; 377 | 378 | /** The full name of this transit line. */ 379 | verboseName: string; 380 | } 381 | 382 | /** Options that can be used to define a waypoint. */ 383 | export interface IWaypointOptions { 384 | /** 385 | * The address string of the waypoint. For example, the following strings are valid for this parameter: "Seattle", "1 Microsoft Way, Redmond, WA". Either the address or location property must be specified. 386 | */ 387 | address?: string; 388 | 389 | /** 390 | * A boolean indicating whether the waypoint is a via point. A via point is a point along the route that is not a stop point. Set this property to 391 | * true if you just want the route to pass through this location. Default: false 392 | */ 393 | isViaPoint?: boolean; 394 | 395 | /** The location of the waypoint. Either the address or location property must be specified. */ 396 | location?: Location; 397 | } 398 | 399 | /** Contains options for the directions to calculate. */ 400 | export interface IDirectionsRequestOptions { 401 | /** The unit to use when displaying direction distances. */ 402 | distanceUnit?: DistanceUnit; 403 | 404 | /** The number of routes to calculate. */ 405 | maxRoutes?: number; 406 | 407 | /** The features to avoid when calculating the route. */ 408 | routeAvoidance?: RouteAvoidance[]; 409 | 410 | /** A boolean indicating whether the route line on the map can be dragged with the mouse cursor. */ 411 | routeDraggable?: boolean; 412 | 413 | /** If multiple routes are returned, the index of the route and directions to display. */ 414 | routeIndex?: number; 415 | 416 | /** The type of directions to calculate. */ 417 | routeMode?: RouteMode; 418 | 419 | /** The optimization setting for the route calculation. */ 420 | routeOptimization?: RouteOptimization; 421 | 422 | /** The type of the time specified. The default value is departure. */ 423 | timeType?: TimeType; 424 | 425 | /** The time to use when calculating the route. If this property is set to null, the current time is used */ 426 | time?: Date; 427 | 428 | /** Specifies the vehicle attributes to use when calculating a truck route. */ 429 | vehicleSpec?: IVehicleSpec; 430 | } 431 | 432 | /** Represents render options for a route. */ 433 | export interface IDirectionsRenderOptions { 434 | /** A boolean indicating whether to automatically set the map view to the best map view of the calculated route. Default: true */ 435 | autoUpdateMapView?: boolean; 436 | 437 | /** A boolean indicating whether to display the disclaimer about the accuracy of the directions. Default: true */ 438 | displayDisclaimer?: boolean; 439 | 440 | /** A boolean indicating whether to display the icons for each direction maneuver. Default: true */ 441 | displayManeuverIcons?: boolean; 442 | 443 | /** A boolean indicating whether to display direction hints that describe when a direction step was missed. Default: true */ 444 | displayPostItineraryItemHints?: boolean; 445 | 446 | /** 447 | * A boolean indicating whether to display direction hints that describe what to look for before you come to the next 448 | * direction step. The default value is true. 449 | */ 450 | displayPreItineraryItemHints?: boolean; 451 | 452 | /** A boolean indicating whether to display the route selector control. Default: true */ 453 | displayRouteSelector?: boolean; 454 | 455 | /** A boolean indicating whether to display direction warnings. Default: true */ 456 | displayStepWarnings?: boolean; 457 | 458 | /** A boolean indicating whether to display a warning about walking directions. Default: true */ 459 | displayWalkingWarning?: boolean; 460 | 461 | /** The polyline options that define how to draw the route line on the map, if the RouteMode is driving. */ 462 | drivingPolylineOptions?: IPolylineOptions; 463 | 464 | /** The pushpin options that define how the first waypoint should be rendered. */ 465 | firstWaypointPushpinOptions?: IPushpinOptions; 466 | 467 | /** The DOM element inside which the directions itinerary will be rendered. */ 468 | itineraryContainer?: HTMLElement; 469 | 470 | /** The pushpin options that define how the last waypoint should be rendered. */ 471 | lastWaypointPushpinOptions?: IPushpinOptions; 472 | 473 | /** A boolean indicating whether to show the input panel. Default: false */ 474 | showInputPanel?: boolean; 475 | 476 | /** The options that define how to draw the route line on the map, if the RouteMode is transit. */ 477 | transitPolylineOptions?: IPolylineOptions; 478 | 479 | /** The options that define how to draw the route line on the map, if the RouteMode is walking. */ 480 | walkingPolylineOptions?: IPolylineOptions; 481 | 482 | /** The options that define the pushpin to use for all route waypoints by default. The first and last waypoints in the route will be overriden by firstWaypointPushpinOptions and lastWaypointPushpinOptions if set. */ 483 | waypointPushpinOptions?: IPushpinOptions; 484 | } 485 | 486 | /** Specifies the vehicle attributes to use when calculating a truck route. */ 487 | export interface IVehicleSpec { 488 | /** 489 | * The unit of measurement of width, height, length. Can be one of the following values: 490 | * • meter or m [default] 491 | * • foot or ft 492 | */ 493 | dimensionUnit?: string; 494 | 495 | /** 496 | * The unit of measurement of weight. Can be one of the following values: 497 | * • kilogram or kg [default] 498 | * • pound or lb 499 | */ 500 | weightUnit?: string; 501 | 502 | /** The height of the vehicle in the specified dimension units. */ 503 | vehicleHeight?: number; 504 | 505 | /** The width of the vehicle in the specified dimension units. */ 506 | vehicleWidth?: number; 507 | 508 | /** The length of the vehicle in the specified dimension units. */ 509 | vehicleLength?: number; 510 | 511 | /** The weight of the vehicle in the specified weight units. */ 512 | vehicleWeight?: number; 513 | 514 | /** The number of axles. */ 515 | vehicleAxles?: number; 516 | 517 | /** The number of trailers. */ 518 | vehicleTrailers?: number; 519 | 520 | /** Indicates if the truck is pulling a semi-trailer. Semi-trailer restrictions are mostly used in North America. */ 521 | vehicleSemi?: boolean; 522 | 523 | /** The maximum gradient the vehicle can drive measured in degrees. */ 524 | vehicleMaxGradient?: boolean; 525 | 526 | /** The minimum required radius for the vehicle to turn in the specified dimension units. */ 527 | vehicleMinTurnRadius?: number; 528 | 529 | /** Indicates if the vehicle shall avoid crosswinds. */ 530 | vehicleAvoidCrossWind?: boolean; 531 | 532 | /** Indicates if the route shall avoid the risk of grounding. */ 533 | vehicleAvoidGroundingRisk?: boolean; 534 | 535 | /** 536 | * A comma separated and case-sensitive list of one or more hazardous materials for which the vehicle is transporting. Possible values and their aliases are: 537 | * 538 | * • Combustable or C 539 | * • Corrosive or Cr 540 | * • Explosive or E 541 | * • Flammable or F 542 | * • FlammableSolid or FS 543 | * • Gas or G 544 | * • GoodsHarmfulToWater or WH 545 | * • Organic or O 546 | * • Other 547 | * • Poison or P 548 | * • PoisonousInhalation or PI 549 | * • Radioactive or R 550 | * • None 551 | * 552 | * Example: "WH,R,Poison" 553 | */ 554 | vehicleHazardousMaterials?: string; 555 | 556 | /** 557 | * A comma separated and case-sensitive list of one or more hazardous materials for which the vehicle has a permit. Possible values and their aliases are: 558 | * 559 | * • AllAppropriateForLoad 560 | * • Combustible or C 561 | * • Corrosive or Cr 562 | * • Explosive or E 563 | * • Flammable or F 564 | * • FlammableSolid or FS 565 | * • Gas or G 566 | * • Organic or O 567 | * • Poison or P 568 | * • PoisonousInhalation or PI 569 | * • Radioactive or R 570 | * • None 571 | * 572 | * Example: "C,Explosive,Corrosive" 573 | */ 574 | vehicleHazardousPermits?: string; 575 | } 576 | 577 | ///////////////////////////////////// 578 | /// Classes 579 | //////////////////////////////////// 580 | 581 | /** An object used to define a start, end or stop location along a route. */ 582 | export class Waypoint { 583 | /** 584 | * @constructor 585 | * @param options: Options used to define the Waypoint. 586 | */ 587 | constructor(options: IWaypointOptions); 588 | 589 | /** Releases any resources associated with the waypoint. */ 590 | public dispose(): void; 591 | 592 | /** 593 | * Gets the address associated with the waypoint. 594 | * @returns The address associated with the waypoint. 595 | */ 596 | public getAddress(): string; 597 | 598 | /** 599 | * Gets the location of the waypoint. 600 | * @returns The location of the waypoint. 601 | */ 602 | public getLocation(): Location; 603 | 604 | /** 605 | * Gets a boolean value indicating whether the waypoint is a via point. 606 | * @returns A boolean value indicating whether the waypoint is a via point. 607 | */ 608 | public isViapoint(): boolean; 609 | 610 | /** 611 | * Sets options for the waypoint. For these options to take effect, you must recalculate the route. 612 | * @param options Options used to define the Waypoint. 613 | */ 614 | public setOptions(options: IWaypointOptions): void; 615 | } 616 | 617 | /** The main class in the Directions module that process direction calculations and rendering. */ 618 | export class DirectionsManager { 619 | 620 | /** 621 | * @constructor 622 | * @param map A map to calculate directions for. 623 | * @param waypoints An array of waypoints to be added to the route. 624 | */ 625 | constructor(map: Map, waypoints?: Waypoint[]); 626 | 627 | /** 628 | * Adds a waypoint to the route at the given index, if specified. If an index is not specified, the waypoint is added as the last waypoint in the route. The maximum number of walking or driving waypoints is 25. The maximum number of transit waypoints is 2. Up to 10 via points are allowed between two stop waypoints. To recalculate the route, use calculateDirections. 629 | * @param waypoint The waypoint to be added to the directions manager. 630 | * @param index An index at which the waypoint is to be added. 631 | */ 632 | public addWaypoint(waypoint: Waypoint, index?: number): void; 633 | 634 | /** 635 | * Calculates directions based on request and render options set 636 | */ 637 | public calculateDirections(): void; 638 | 639 | /** Clears the directions request and render options and removes all waypoints */ 640 | public clearAll(): void; 641 | 642 | /** 643 | * Clears the directions displayed and removes the route line from the map. 644 | * This method does not remove waypoints from the route and retains all calculated direction information and option settings. 645 | */ 646 | public clearDisplay(): void; 647 | 648 | /** Deletes the DirectionsManager object and releases any associated resources. */ 649 | public dispose(): void; 650 | 651 | /** 652 | * Returns all current pushpins for the rendered route.This includes pushpins created by addWaypoint and viaPoints created due to drag and drop. 653 | */ 654 | public getAllPushpins(): Pushpin[]; 655 | 656 | /** 657 | * Gets all the waypoints in the directions manager. 658 | * @returns All the waypoints in the directions manager. 659 | */ 660 | public getAllWaypoints(): Waypoint[]; 661 | 662 | /** 663 | * Gets the currently displayed route information. 664 | * @returns The currently displayed route information. 665 | */ 666 | public getCurrentRoute(): IRoute; 667 | 668 | /** 669 | * Gets the route render options. 670 | * @returns The route render options 671 | */ 672 | public getRenderOptions(): IDirectionsRenderOptions; 673 | 674 | /** 675 | * Gets the directions request options. 676 | * @returns The directions request options. 677 | */ 678 | public getRequestOptions(): IDirectionsRequestOptions; 679 | 680 | /** 681 | * Gets the current calculated route(s) 682 | * @returns The current calculated route(s). If the route was not successfully calculated, null is returned. 683 | */ 684 | public getRouteResult(): IRoute[]; 685 | 686 | /** 687 | * Removes the given waypoint or the waypoint identified by the given index from the route. 688 | * @param waypointOrIndex A Waypoint object to be removed or the index of the waypoint to be removed 689 | */ 690 | public removeWaypoint(waypointOrIndex: Waypoint | number): void; 691 | 692 | /** 693 | * Sets the specified render options for the route. 694 | * @param options The options that customize the rendering of the calculated route. 695 | */ 696 | public setRenderOptions(options: IDirectionsRenderOptions): void; 697 | 698 | /** 699 | * Sets the specified route calculation options. 700 | * @param options The route calculation options. 701 | */ 702 | public setRequestOptions(options: IDirectionsRequestOptions): void; 703 | 704 | /** 705 | * Displays an input panel for calculating directions in the specified container. Provides autosuggest for location inputs. 706 | * @param inputContainerId The id name of the HTML container in which to render the directions input panel. 707 | */ 708 | public showInputPanel(inputContainerId: string): void; 709 | } 710 | } 711 | 712 | declare module Microsoft.Maps { 713 | /** A static class that manages events within the map SDK. */ 714 | module Events { 715 | ///////////////////////////////////// 716 | /// addHandler Definitions 717 | //////////////////////////////////// 718 | 719 | /** 720 | * Attaches the handler for the event that is thrown by the target. Use the return object to remove the handler using the removeHandler method. 721 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 722 | * @param eventName The type of event to attach. Supported Events: 723 | * • directionsError 724 | * • directionsUpdated 725 | * @param handler The callback function to handle the event when triggered. 726 | * @returns The handler id. 727 | */ 728 | export function addHandler(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void): IHandlerId; 729 | 730 | ///////////////////////////////////// 731 | /// addOne Definitions 732 | //////////////////////////////////// 733 | 734 | /** 735 | * Attaches the handler for the event that is thrown by the target, but only triggers the handler the first once after being attached. 736 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 737 | * @param eventName The type of event to attach. Supported Events: 738 | * • directionsError 739 | * • directionsUpdated 740 | * @param handler The callback function to handle the event when triggered. 741 | */ 742 | export function addOne(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void): void; 743 | 744 | ///////////////////////////////////// 745 | /// addThrottledHandler Definitions 746 | //////////////////////////////////// 747 | 748 | /** 749 | * Attaches the handler for the event that is thrown by the target, where the minimum interval between events (in milliseconds) is specified as a parameter. 750 | * @param target The object to attach the event to; Map, IPrimitive, Infobox, Layer, DrawingTools, DrawingManager, DirectionsManager, etc. 751 | * @param eventName The type of event to attach. Supported Events: 752 | * • directionsError 753 | * • directionsUpdated 754 | * @param handler The callback function to handle the event when triggered. 755 | * @param throttleInterval throttle interval (in ms) 756 | * @returns The handler id. 757 | */ 758 | export function addThrottledHandler(target: Directions.DirectionsManager, eventName: string, handler: (eventArg?: Directions.IDirectionsEventArgs | Directions.IDirectionsErrorEventArgs) => void, throttleInterval: number): IHandlerId; 759 | } 760 | } 761 | --------------------------------------------------------------------------------