forked from microsoft/Bing-Maps-V8-TypeScript-Definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.ts
55 lines (44 loc) · 1.66 KB
/
Example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/// <reference path="scripts/MicrosoftMaps/Microsoft.Maps.All.d.ts" />
var map = new Microsoft.Maps.Map('#MyMap', {
credentials: 'Your Bing Maps Key'
});
Microsoft.Maps.Events.addHandler(map, 'click', (e: Microsoft.Maps.IMouseEventArgs) => {
//The location on the map that the user clicked.
var loc = e.location;
});
var layer = new Microsoft.Maps.Layer();
var pin = new Microsoft.Maps.Pushpin(map.getCenter(), {
color: new Microsoft.Maps.Color(150, 150, 0, 0)
});
Microsoft.Maps.Events.addOne(pin, 'changed', (e: Microsoft.Maps.IPrimitiveChangedEventArgs) => {
//e.name => name of property that changed.
//e.sender => reference to the pushpin object that changed.
});
layer.add(pin);
map.layers.insert(layer);
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJSON', () => {
Microsoft.Maps.GeoJSON.readFromUrl('URL to file', (data) => {
if (data instanceof Array) {
//Data is an array of shapes.
} else {
//Data is a single shape.
}
map.entities.push(data);
});
});
Microsoft.Maps.loadModule('Microsoft.Maps.Autosuggest', {
credentials: 'Your Bing Maps Key',
callback: () => {
var asManager = new Microsoft.Maps.AutosuggestManager();
asManager.attachAutosuggest('mySuggestionTextbox', 'suggestionsContainer', (result) => {
//Do something with the selected result.
});
}
});
Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', {
credentials: 'Your Bing Maps Key',
callback: () => {
var drawingTools = new Microsoft.Maps.DrawingTools(map);
drawingTools.create(Microsoft.Maps.DrawingTools.ShapeType.polyline);
}
});