Merge pull request #3264 from ericrtodd/master

Adding typings for Bing Maps API.  These are for use with the Bing Maps ...
This commit is contained in:
John Reilly
2014-12-26 05:12:56 +00:00
8 changed files with 1513 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for Microsoft.Maps.AdvancedShapes 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh921952.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="Microsoft.Maps.d.ts"/>
declare module Microsoft.Maps.AdvancedShapes {
export class EntityCollection {
constructor(options: EntityCollectionOptions);
clear(): void;
get(index: number): Entity;
getLength(): number;
getVisible(): boolean;
getZIndex(): number;
indexOf(entity: Entity): number;
insert(entity: Entity, index: number): void;
pop(): Entity;
push(entity: Entity): void;
remove(entity: Entity): Entity;
removeAt(index: number): Entity;
setOptions(options: EntityCollectionOptions): void;
toString(): string;
entityAdded: (args: EntityChangeArgs) => any;
entityChanged: (args: EntityChangeArgs) => any;
entityRemoved: (args: EntityChangeArgs) => any;
}
export class Polygon implements Entity {
constructor(locations: Array<Location>, options?: PolygonOptions);
getFillColor(): Color;
getLocations(): Array<Location>;
getStrokeColor(): Color;
getStrokeDashArray(): string;
getStrokeThickness(): number;
getVisible(): boolean;
setLocations(locations: Location[]): void;
setOptions(options: PolylineOptions): void;
toString(): string;
click: (eventArgs: MouseEventArgs) => void;
dbclick: (eventArgs: MouseEventArgs) => void;
entitychanged: (entity: Entity) => void;
mousedown: (eventArgs: MouseEventArgs) => void;
mouseout: (eventArgs: MouseEventArgs) => void;
mouseover: (eventArgs: MouseEventArgs) => void;
mouseup: (eventArgs: MouseEventArgs) => void;
rightclick: (eventArgs: MouseEventArgs) => void;
}
}
+461
View File
@@ -0,0 +1,461 @@
// Type definitions for Microsoft.Maps.Directions 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh312813.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="Microsoft.Maps.d.ts"/>
declare module Microsoft.Maps.Directions {
export interface BusinessDetails {
businessName?: string;
entityId?: string;
phoneNumber?: string;
website?: string;
}
export interface WaypointOptions {
address?: string;
businessDetails?: BusinessDetails;
disambiguationContainer?: HTMLElement;
exactLocation?: string;
isViapoint?: boolean;
location?: Location;
pushpin?: Pushpin;
shortAddress?: string;
}
export interface BusinessDisambiguationSuggestion {
address?: string;
distance?: number;
entityId?: number;
index?: number;
isApproximate?: boolean;
location?: Location;
name?: string;
phoneNumber?: string;
photoUrl?: string;
rooftopLocation?: Location;
website?: string;
}
export interface LocationDisambiguationSuggestion {
formattedSuggestion?: string;
location?: Location;
rooftopLocation?: Location;
suggestion?: string;
}
export interface Disambiguation {
businessSuggestions?: Array<BusinessDisambiguationSuggestion>;
hasMoreSuggestions?: boolean;
headerText?: string;
locationSuggestions?: Array<LocationDisambiguationSuggestion>;
}
export interface WaypointEventArgs {
waypoint: Waypoint;
}
export class Waypoint {
constructor(options: WaypointOptions);
clear(): void;
dispose(): void;
getAddress(): string;
getBusinessDetails(): BusinessDetails;
getDisambiguationContainer(): HTMLElement;
getDisambiguationResult(): Disambiguation;
getLocation(): Location;
getPushpin(): Pushpin;
getShortAddress(): string;
isExactLocation(): boolean;
isViapoint(): boolean;
setOptions(options: WaypointOptions): void;
changed: (args: WaypointEventArgs) => void;
geocoded: (args: WaypointEventArgs) => void;
reverseGeocoded: (args: WaypointEventArgs) => void;
}
export interface DirectionsRenderOptions {
autoDisplayDisambiguation?: boolean;
autoUpdateMapView?: boolean;
disambiguationPushpinOptions?: PushpinOptions;
displayDisclaimer?: boolean;
displayManeuverIcons?: boolean;
displayPostItineraryItemHints?: boolean;
displayPreItineraryItemHints?: boolean;
displayRouteSelector?: boolean;
displayStepWarnings?: boolean;
displayTrafficAvoidanceOption?: boolean;
displayWalkingWarning?: boolean;
drivingPolylineOptions?: PolylineOptions;
itineraryContainer?: HTMLElement;
lastWaypointIcon?: string;
middleWaypointIcon?: string;
stepPushpinOptions?: PushpinOptions;
transitPolylineOptions?: PolylineOptions;
viapointPushpinsOptions?: PushpinOptions;
walkingPolylineOptions?: PolylineOptions;
waypointPushpinOptions?: PushpinOptions;
}
export enum DistanceUnit {
kilometers= 0,
miles= 1
}
export enum RouteAvoidance {
none= 0,
minimizeLimitedAccessHighway= 1,
minimizeToll= 2,
avoidLimitedAccessHighway= 4,
avoidToll= 8,
avoidExpressTrain= 16,
avoidAirline= 32,
avoidBulletTrain= 64
}
export enum RouteMode {
driving,
transit,
walking
}
export enum RouteOptimization {
shortestTime= 0,
shortestDistance= 1,
minimizeMoney= 3,
minimizeTransfers= 4,
minimizeWalking= 5
}
export enum TimeType {
arrival,
departure,
lastAvailable
}
export interface TransitOptions {
timeType?: TimeType;
transitTime?: Date;
}
export interface DirectionsRequestOptions {
avoidTraffic?: boolean;
distanceUnit?: DistanceUnit;
maxRoutes?: number;
routeAvoidance?: Array<RouteAvoidance>;
routeDraggable?: boolean;
routeIndex?: boolean;
routeMode?: RouteMode;
routeOptimization?: RouteOptimization;
transitOptions?: TransitOptions;
}
export class DirectionsManager {
constructor(map: Microsoft.Maps.Map);
resetDirections(): void;
addWaypoint(waypoint: Waypoint, index?: number): void;
calculateDirections(): void;
clearDisplay(): void;
dispose(): void;
getAllWaypoints(): Array<Waypoint>;
getMap(): Map;
getNearbyMajorRoads(location: Location, callback: any, errorCallback: any, userData: any): void;
getRenderOptions(): DirectionsRenderOptions;
getRequestOptions(): DirectionsRequestOptions;
getRouteResult(): Array<Route>;
removeWaypoint(waypoint: Waypoint): void;
removeWaypoint(index: number): void;
resetDirections(options: ResetDirectionsOptions): void;
reverseGeocode(location: Location, callback: any, errorCallback: any, userData: any): void;
setMapView(): void;
setRenderOptions(options: DirectionsRenderOptions): void;
setRequestOptions(options: DirectionsRequestOptions): void;
afterRouteSelectorRender: (args: RouteSelectorRenderEventArgs) => void;
afterStepRender: (args: DirectionsStepRenderEventArgs) => void;
afterSummaryRender: (args: RouteSummaryRenderEventArgs) => void;
afterWaypointRender: (args: WaypointRenderEventArgs) => void;
beforeDisambiguationRender: (args: DisambiguationRenderEventArgs) => void;
beforeRouteSelectorRender: (args: RouteSelectorRenderEventArgs) => void;
beforeStepRender: (args: DirectionsStepRenderEventArgs) => void;
beforeSummaryRender: (args: RouteSummaryRenderEventArgs) => void;
beforeWaypointRender: (args: WaypointRenderEventArgs) => void;
directionsError: (args: DirectionsErrorEventArgs) => void;
directionsUpdated: (args: DirectionsEventArgs) => void;
dragDropCompleted: () => void;
itineraryStepClicked: (args: DirectionsStepEventArgs) => void;
mouseEnterRouteSelector: (args: RouteSelectorEventArgs) => void;
mouseEnterStep: (args: DirectionsStepEventArgs) => void;
mouseLeaveRouteSelector: (args: RouteSelectorEventArgs) => void;
mouseLeaveStep: (args: DirectionsStepEventArgs) => void;
routeSelectorClicked: (args: RouteSelectorEventArgs) => void;
waypointAdded: (args: WaypointEventArgs) => void;
waypointRemoved: (args: WaypointEventArgs) => void;
}
export interface DirectionsStepEventArgs {
handled: boolean;
location: Location;
routeIndex: number;
routeLegIndex: number;
step: DirectionsStep;
stepIndex: number;
stepNumber: number;
}
export interface DirectionsErrorEventArgs {
responseCode: RouteResponseCode;
message: string;
}
export interface DirectionsEventArgs {
routeSummary: Array<RouteSummary>;
route: Array<Route>;
}
export interface DisambiguationRenderEventArgs {
containerElement: HTMLElement;
handled: boolean;
waypoint: Waypoint;
}
export interface DirectionsStepRenderEventArgs {
containerElement: HTMLElement;
handled: boolean;
lastStep: boolean;
routeIndex: number;
routeLegIndex: number;
step: DirectionsStep;
stepIndex: number;
}
export interface RouteSummaryRenderEventArgs {
containerElement: HTMLElement;
handled: boolean;
routeLegIndex: number;
summary: RouteSummary;
}
export interface WaypointRenderEventArgs {
containerElement: HTMLElement;
handled: boolean;
waypoint: Waypoint;
}
export interface DirectionsStep {
childItineraryItems: Array<DirectionsStep>;
coordinate: Location;
distance: string;
durationInSeconds: number;
formattedText: string;
iconType: IconType;
isImageRoadShield: boolean;
maneuver: Maneuver;
maneuverImageName: string;
monetaryCost: number;
postIntersectionHints: Array<string>;
preIntersectionHings: Array<string>;
startStopName: string;
transitLine: TransitLine;
transitStepIcon: string;
transitStopId: string;
transitTerminus: string;
warnings: Array<DirectionsStepWarning>;
}
export enum IconType {
none,
other,
auto,
ferry,
walk,
bus,
train,
airline
}
export enum Maneuver {
none= 0,
unknown= 1,
departStart= 2,
departIntermediateStop= 3,
departIntermediateStopReturning= 4,
arriveFinish= 5,
arriveIntermediateStop= 6,
turnLeft= 7,
turnRight= 8,
turnBack= 9,
uTurn= 10,
turnToStayLeft= 11,
turnToStayRight= 12,
bearLeft= 13,
bearRight= 14,
keepToStayLeft= 15,
keepToStayRight= 16,
keepToStayStraight= 17,
keepLeft= 18,
keepRight= 19,
keepStraight= 20,
take= 21,
takeRampLeft= 22,
takeRampRight= 23,
takeRampStraight= 24,
keepOnRampLeft= 25,
keepOnRampRight= 26,
keepOnRampStraight= 27,
merge= 28,
continueRoute= 29,
roadNameChange= 30,
enterRoundabout= 31,
exitRoundabout= 32,
turnRightThenTurnRight= 33,
turnRightThenTurnLeft= 34,
turnRightThenBearRight= 35,
turnRightThenBearLeft= 36,
turnLeftThenTurnLeft= 37,
turnLeftThenTurnRight= 38,
turnLeftThenBearLeft= 39,
turnLeftThenBearRight= 40,
bearRightThenTurnRight= 41,
bearRightThenTurnLeft= 42,
bearRightThenBearRight= 43,
bearRightThenBearLeft= 44,
bearLeftThenTurnLeft= 45,
bearLeftThenTurnRight= 46,
bearLeftThenBearRight= 47,
bearLeftThenBearLeft= 48,
rampThenHighwayRight= 49,
rampThenHighwayLeft= 50,
rampToHighwayStraight= 51,
enterThenExitRoundabout= 52,
bearThenMerge= 53,
turnThenMerge= 54,
bearThenKeep= 55,
transfer= 56,
wait = 57,
takeTransit= 58,
walk = 59,
transitDepart = 60,
transitArrive= 61,
}
export interface TransitLine {
abbreviatedName: string;
agencyId: number;
agencyName: string;
agencyUrl: string;
lineColor: Color;
lineTextColor: Color;
providerInfo: string;
verboseName: string;
}
export interface DirectionsStepWarning {
style: StepWarningStyle;
text: string;
}
export enum StepWarningStyle {
info= 0,
minor= 1,
moderate= 2,
major= 3,
ccZoneEnter= 4,
ccZoneExit= 5
}
export interface ResetDirectionsOptions {
removeAllWaypoints?: boolean;
resetRenderOptions?: boolean;
resetRequestOptions?: boolean;
}
export interface Route {
routeLegs: Array<RouteLeg>;
}
export interface RouteLeg {
endTime: Date;
endWaypointLocation: Location;
itineraryItems: Array<DirectionsStep>;
originalRouteIndex: number;
startTime: Date;
startWaypointLocation: Location;
subLegs: Array<RouteSubLeg>;
summary: RouteSummary;
}
export interface RouteSubLeg {
actualEnd: Location;
actualStart: Location;
endDescription: string;
routePath: RoutePath;
startDescription: string;
summary: RouteSummary;
}
export interface RoutePath {
decodedLatitudes: Array<number>;
decodedLongitudes: Array<number>;
decodedRegions: Array<any>;
}
export interface RouteSummary {
distance: number;
monetaryCost: number;
northEast: Location;
southWest: Location;
time: number;
timeWithTraffic: number;
}
export enum RouteResponseCode {
success= 0,
unknownError= 1,
cannotFindNearbyRoad= 2,
tooFar= 3,
noSolution= 4,
dataSourceNotFound= 5,
noAvailableTransitTrip= 7,
transitStopsTooClose= 8,
walkingBestAlternative= 9,
outOfTransitBounds= 10,
timeout= 11,
waypointDisambiguation= 12,
hasEmptyWaypoint= 13,
exceedMaxWaypointLimit= 14,
atleastTwoWaypointRequired= 15,
firstOrLastStoppointsIsVia= 16,
searchServiceFailed= 17,
invalidCredentials= 18
}
export interface RouteSelectorEventArgs {
handled: boolean;
routeIndex: number;
}
export interface RouteSelectorRenderEventArgs {
containerElement: HTMLElement;
handled: boolean;
routeIndex: number;
routeLeg: RouteLeg;
}
}
+152
View File
@@ -0,0 +1,152 @@
// Type definitions for Microsoft.Maps.Search 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh868061.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="Microsoft.Maps.d.ts"/>
declare module Microsoft.Maps.Search {
export interface Address {
addressLine: string;
adminDistrict: string;
countryRegion: string;
district: string;
formattedAddress: string;
locality: string;
postalCode: string;
postalTown:string;
}
export interface GeocodeLocation {
location: Location;
name: string;
precision:LocationPrecision;
}
export interface GeocodeRequestOptions {
bounds: LocationRect;
callback: (result: GeocodeResult, userData: any) => any;
count: number;
errorCallback: (options: GeocodeRequestOptions) => any;
timeout: number;
userData: any;
where:string;
}
export interface GeocodeResult {
parsedAddress: Address;
parsedKeyword: string;
parsedSeparator: string;
results:Array<PlaceResult>;
}
export enum LocationPrecision {
interpolated,
rooftop,
}
export enum MatchCode {
none,
good,
ambiguous,
upHierarchy,
modified,
}
export enum MatchConfidence {
high,
medium,
low,
unknown,
}
export interface PlaceResult {
bestView: LocationRect;
location: GeocodeLocation;
locations: Array<GeocodeLocation>;
matchCode: MatchCode;
matchConfidence: MatchConfidence;
name:string;
}
export interface ReverseGeocodeRequestOptions {
callback: (result: PlaceResult, userData: any) => any;
errorCallback: (options: ReverseGeocodeRequestOptions) => any;
location: Location;
timeout: number;
userData:any;
}
export class SearchManager {
constructor(map: Map);
geocode(request: GeocodeRequestOptions): void;
reverseGeocode(request: ReverseGeocodeRequestOptions): void;
search(request:SearchRequestOptions):void;
}
export interface SearchParseResult {
keyword: string;
location: GeocodeLocation;
matchConfidence:MatchConfidence;
}
export interface SearchRegion {
address: Address;
geocodeLocations: Array<GeocodeLocation>;
explicitLocation: GeocodeLocation;
mapBounds: LocationRect;
matchCode: MatchCode;
matchConfidence: MatchConfidence;
source:string;
}
export interface SearchRequestOptions {
callback:(result: SearchResponse, userData: any)=>any;
count: number;
errorCallback:(options: SearchRequestOptions)=>any;
query: string;
startIndex: number;
timeout: number;
entityType: string;
userData: any;
what: string;
where:string;
}
export interface SearchResponse {
alternateSearchRegions: Array<SearchRegion>;
hasMore: boolean;
parseResults: Array<SearchParseResult>;
responseSummary: SearchResponseSummary;
searchRegion: SearchRegion;
searchResults:Array<SearchResult>;
}
export interface SearchResponseSummary {
authResultCode: number;
copyright: string;
errorMessage: string;
statusCode: number;
traceId:number;
}
export interface SearchResult {
address: Address;
city: string;
country: string;
entityType: string;
hoursOfOperation: string;
id: number;
location: Location;
name: string;
phone: string;
postalCode: string;
reviewCount: number;
userRating: number;
website:string;
}
}
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for Microsoft.Maps.Themes 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh868061.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Microsoft.Maps.Themes {
export class BingTheme {
constructor();
}
}
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for Microsoft.Maps.Traffic 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh312840.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="Microsoft.Maps.d.ts"/>
declare module Microsoft.Maps.Traffic {
export class TrafficManager {
constructor(map: Map);
hide(): void;
hideFlow(): void;
hideIncidents(): void;
hideLegend(): void;
show(): void;
showFlow(): void;
showIncidents(): void;
showLegend():void;
}
}
+141
View File
@@ -0,0 +1,141 @@
// Type definitions for Microsoft.Maps.VenueMaps 7.0
// Project: http://msdn.microsoft.com/en-us/library/hh312797.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="Microsoft.Maps.d.ts"/>
declare module Microsoft.Maps.VenueMaps {
export interface MouseResponse {
eventArgs: MouseEventArgs;
}
export interface Directory {
addToDOM(div: HTMLElement, sortOrder: DirectorySortOrder, to_group_or_not: DirectoryGrouping): void;
createUIElements(): void;
handleMouseClick(response: MouseResponse): void;
handleMouseOut(response: MouseResponse): void;
handleMouseOver(response: MouseResponse): void;
isInDOM(): boolean;
removeFromDOM(): void;
setHeight(height: number): void;
click: (eventArgs: MouseEventArgs) => any;
mouseOut: (eventArgs: MouseEventArgs) => any;
mouseOver: (eventArgs: MouseEventArgs) => any;
}
export enum DirectoryGrouping {
byCategory,
none,
}
export enum DirectorySortOrder {
alphabetical,
byFloor,
}
export interface Floor {
name: string;
primitives: Array<Primitive>;
zoomRange: Array<number>;
}
export interface Footprint {
polygons: Array<Polygon>;
zoomRange: Array<number>;
}
export interface Metadata {
CenterLatitude: number;
CenterLongitude: number;
DefaultFloor: string;
FloorHeader: string;
Floors: Array<Floor>;
Footprint: Footprint;
MapId: string;
MapType: string;
Name: string;
YpId: string;
}
export interface NearbyVenue {
distance: number;
metadata: Metadata;
}
export interface NearbyVenueOptions {
callback: (maps: Array<VenueMap>) => any;
location: Location;
map: Map;
radius: number;
}
export interface Polygon {
bounds: LocationRect;
center: Location;
locations: Array<Location>;
}
export interface Primitive {
bounds: LocationRect;
businessId: string;
categoryId: string;
categoryName: string;
center: Location;
floor: Floor;
id: string;
locations: Array<Location>;
name: string;
highlight(): void;
unhighlight(): void;
}
export interface VenueMap {
address: string;
bestMapView: ViewOptions;
businessId: string;
center: Location;
defaultFloor: string;
directory: Directory;
floorHeader: string;
floors: Array<Floor>;
footprint: Footprint;
id: string;
name: string;
phoneNumber: string;
type: string;
dispose(): void;
getActiveFloor(): string;
hide(): void;
setActiveFloor(floor: string): void;
show(): void;
click: (eventArgs: Primitive) => any;
close: () => any;
footprintclick: (eventArgs: Primitive) => any;
mouseout: (eventArgs: Primitive) => any;
mouseover: (eventArgs: Primitive) => any;
}
export interface VenueMapCreationOptions {
error: (errorCode: number, args: any) => any;
success: (venueMap: VenueMap, args: any) => any;
venueMapId: string;
}
export class VenueMapFactory {
constructor(map: Map);
create(options: VenueMapCreationOptions): void;
getNearbyVenues(options: NearbyVenueOptions): void;
}
}
+573
View File
@@ -0,0 +1,573 @@
// Type definitions for Microsoft.Maps 7.0
// Project: http://msdn.microsoft.com/en-us/library/gg427611.aspx
// Definitions by: Eric Todd <https://github.com/ericrtodd>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Microsoft.Maps {
export enum AltitudeReference {
ground,
ellipsoid
}
export class Location {
constructor(latitude: number, longitude: number, altitude?: number, altitudeReference?: AltitudeReference);
altitude: number;
altitudeReference: AltitudeReference;
latitude: number;
longitude: number;
static areEqual(location1: Location, location2: Location): boolean;
static normalizeLongitude(longitude: number): number;
clone(): Location;
toString(): string;
}
export class LocationRect {
constructor(center: Location, width: number, height: number);
center: Location;
height: number;
width: number;
static fromCorners(northwest: Location, southeast: Location): LocationRect;
static fromEdges(north: number, west: number, south: number, east: number, altitude: number, altitudeReference: AltitudeReference): LocationRect;
static fromLocations(locations: Array<Location>): LocationRect;
static fromString(value: string): LocationRect;
clone(): LocationRect;
contains(location: Location): boolean;
getEast(): number;
getNorth(): number;
getNorthwest(): Location;
getSouth(): number;
getSouthEast(): Location;
getWest(): number;
intersects(rect: LocationRect): boolean;
toString(): string;
}
export class Point {
constructor(x: number, y: number);
x: number;
y: number;
static areEqual(p1: Point, p2: Point): boolean;
static clone(p: Point): Point;
clone(): Point;
toString(): string;
}
export class Events {
static addHandler(target: any, eventName: string, handler: () => void): any;
static addThrottledHandler(target: any, eventName: string, handler: () => void, throttleInterval: number): any;
static hasHandler(target: any, eventName: string): boolean;
static invoke(target: any, eventName: string, args: any): void;
static removeHandler(handlerId: any): void;
}
export interface KeyEventArgs {
altKey: boolean;
ctrlKey: boolean;
eventName: boolean;
handled: boolean;
keyCode: string;
originalEvent: any;
shiftKey: boolean;
}
export enum LabelOverlay {
hidden,
visible
}
export interface ZoomRange {
min: number;
max: number;
}
export class Map {
constructor(containerElement: HTMLElement, options: MapOptions);
entities: EntityCollection;
static getVersion(): string;
blur(): void;
dispose(): void;
focus(): void;
getBounds(): LocationRect;
getCenter(): Location;
getCopyrights(callback: (copyrights: Array<string>) => void): void;
getCredentials(callback: (credentials: Array<string>) => void): void;
getHeading(): string;
getHeight(): number;
getImageryId: string;
getMapTypeId(): string;
getMetersPerPixel(): number;
getMode(): MapMode;
getModeLayer(): HTMLElement;
getOptions(): MapOptions;
getPageX(): number;
getPageY(): number;
getRootElement(): HTMLElement;
getTargetBounds(): LocationRect;
getTargetCenter(): Location;
getTargetHeading(): number;
getTargetMetersPerPixel(): number;
getTargetZoom(): number;
getUserLayer(): HTMLElement;
getViewportX(): number;
getViewportY(): number;
getWidth(): number;
getZoom(): number;
getZoomRange(): ZoomRange;
isDownloadingTiles(): boolean;
isMercator(): boolean;
isRotationEnabled(): boolean;
setMapType(mapTypeId: MapTypeId): void;
setOptions(options: MapOptions): void;
setView(options: ViewOptions): void;
tryLocationToPixel(locations: Array<Location>, reference?: PixelReference): any;
tryPixelToLocation(points: Array<Point>, reference?: PixelReference): any;
click: (eventArgs: MouseEventArgs) => void;
copyrightchanged: () => void;
dblclick: (eventArgs: MouseEventArgs) => void;
imagerychanged: () => void;
keydown: (eventArgs: KeyEventArgs) => void;
keypress: (eventArgs: KeyEventArgs) => void;
keyup: (eventArgs: KeyEventArgs) => void;
maptypechanged: () => void;
mousedown: (eventArgs: MouseEventArgs) => void;
mousemove: (eventArgs: MouseEventArgs) => void;
mouseout: (eventArgs: MouseEventArgs) => void;
mouseover: (eventArgs: MouseEventArgs) => void;
mouseup: (eventArgs: MouseEventArgs) => void;
mousewheel: (eventArgs: MouseEventArgs) => void;
rightlick: (eventArgs: MouseEventArgs) => void;
targetviewchanged: () => void;
tiledownloadcomplete: () => void;
viewchange: () => void;
viewchangeend: () => void;
viewchangestart: () => void;
}
export class MapMode {
getDrawShapesInSingleLayer(): boolean;
getShouldClipPolygons(): boolean;
setOptions(options: MapOptions): void;
setViewChangeEndDelay(delay: number): void;
}
export interface MapOptions {
backgroundColor?: Color;
credentials?: string;
customizeOverlays?: boolean;
disableBirdseye?: boolean;
disableKeyboardInput?: boolean;
disableMouseInput?: boolean;
disablePanning?: boolean;
disableTouchInput?: boolean;
disableUserInput?: boolean;
disableZooming?: boolean;
enableClickableLogo?: boolean;
enableSearchLogo?: boolean;
fixedMapPosition?: boolean;
height?: number;
inertiaIntensity?: number;
showBreadcrumb?: boolean;
showCopyright?: boolean;
showDashboard?: boolean;
showMapTypeSelector?: boolean;
showScalebar?: boolean;
theme?: any;
tileBuffer?: number;
useInertia?: boolean;
width?: number;
center?: Location;
zoom?: number;
mapTypeId?: MapTypeId;
}
export enum MapTypeId {
aerial,
auto,
birdseye,
collinsBart,
mercator,
ordnanceSurvey,
road
}
export class MouseEventArgs {
eventName: string;
handled: boolean;
isPrimary: boolean;
isSecondary: boolean;
isTouchEvent: boolean;
originalEvent: any;
pageX: number;
pageY: number;
target: any;
targetType: string;
wheelDelta: number;
getX(): number;
getY(): number;
}
export enum PixelReference {
control,
page,
viewport
}
export interface ViewOptions {
animate?: boolean;
bounds?: LocationRect;
center?: Location;
centerOffset?: Point;
heading?: number;
labelOverlay?: LabelOverlay;
mapTypeId?: string;
padding?: number;
zoom?: number;
}
export class Color {
constructor(alpha: number, red: number, green: number, blue: number);
a: number;
r: number;
g: number;
b: number;
static clone(color: Color): Color;
static fromHex(hex: string): Color;
clone(): Color;
getOpacity(): number;
toHex(): string;
toString(): string;
}
export interface EntityChangeArgs {
collection: EntityCollection;
entity: Entity;
}
export interface EntityCollectionOptions {
bubble: boolean;
visible: boolean;
zIndex: number;
}
export class EntityCollection {
constructor(options: EntityCollectionOptions);
clear(): void;
get(index: number): Entity;
getLength(): number;
getVisible(): boolean;
getZIndex(): number;
indexOf(entity: Entity): number;
insert(entity: Entity, index: number): void;
pop(): Entity;
push(entity: Entity): void;
remove(entity: Entity): Entity;
removeAt(index: number): Entity;
setOptions(options: EntityCollectionOptions): void;
toString(): string;
entityAdded: (args: EntityChangeArgs) => any;
entityChanged: (args: EntityChangeArgs) => any;
entityRemoved: (args: EntityChangeArgs) => any;
}
export class Infobox {
constructor(location: Location, options?: InfoboxOptions);
getActions(): any;
getAnchor(): Point;
getDescription(): string;
getHeight(): number;
getHtmlContent(): string;
getId(): string;
getLocation(): Location;
getOffset(): Point;
getOptions(): InfoboxOptions;
getShowCloseButton(): boolean;
getShowPointer(): boolean;
getTitle(): string;
getTitleAction(): any;
getTitleClickHandler(): () => void;
getVisible(): boolean;
getWidth(): number;
getZIndex(): number;
setHtmlContent(content: string): void;
setLocation(location: Location): void;
setOptions(options: InfoboxOptions): void;
toString(): string;
click: (eventArgs: MouseEventArgs) => void;
entitychanged: (entity: Entity) => void;
mouseenter: (eventArgs: MouseEventArgs) => void;
mouseleave: (eventArgs: MouseEventArgs) => void;
}
export interface Action {
label?: string;
icon?: string;
eventHandler: (args?: any) => void;
}
export interface InfoboxOptions {
actions?: Array<Action>;
description?: string;
htmlContent?: string;
id?: string;
location?: Location;
offset?: Point;
showCloseButton?: boolean;
showPointer?: boolean;
pushpin?: Pushpin;
title?: string;
titleAction?: { label?: string; eventHandler: () => void; };
titleClickHandler?: () => void;
typeName?: InfoboxType;
visible?: boolean;
width?: number;
height?: number;
}
export enum InfoboxType {
mini,
standard
}
export interface Entity {
}
export class Polyline implements Entity {
constructor(locations: Array<Location>, options?: PolylineOptions);
getLocations(): Array<Location>;
getStrokeColor(): Color;
getStrokeDashArray(): string;
getStrokeThickness(): number;
getVisible(): boolean;
setLocations(locations: Array<Location>): void;
setOptions(options: PolylineOptions): void;
toString(): string;
click: (eventArgs: MouseEventArgs) => void;
dblclick: (eventArgs: MouseEventArgs) => void;
entitychanged: (entity: Entity) => void;
mousedown: (eventArgs: MouseEventArgs) => void;
mouseout: (eventArgs: MouseEventArgs) => void;
mouseover: (eventArgs: MouseEventArgs) => void;
mouseup: (eventArgs: MouseEventArgs) => void;
rightclick: (eventArgs: MouseEventArgs) => void;
}
export interface PolylineOptions {
strokeColor: Color;
strokeDashArray: string;
strokeThickness: number;
visible: boolean;
}
export class Polygon implements Entity {
constructor(locations: Array<Location>, options?: PolygonOptions);
getFillColor(): Color;
getLocations(): Array<Location>;
getStrokeColor(): Color;
getStrokeDashArray(): string;
getStrokeThickness(): number;
getVisible(): boolean;
setLocations(locations: Location[]): void;
setOptions(options: PolylineOptions): void;
toString(): string;
click: (eventArgs: MouseEventArgs) => void;
dbclick: (eventArgs: MouseEventArgs) => void;
entitychanged: (entity: Entity) => void;
mousedown: (eventArgs: MouseEventArgs) => void;
mouseout: (eventArgs: MouseEventArgs) => void;
mouseover: (eventArgs: MouseEventArgs) => void;
mouseup: (eventArgs: MouseEventArgs) => void;
rightclick: (eventArgs: MouseEventArgs) => void;
}
export interface PolygonOptions {
strokeColor: Color;
strokeDashArray: string;
strokeThickness: number;
visible: boolean;
}
export class Pushpin implements Entity {
constructor(location: Location, options?: PushpinOptions);
getAnchor(): Point;
getIcon(): string;
getHeight(): number;
getLocation(): Location;
getText(): string;
getTextOffset(): Point;
getTypeName(): string;
getVisible(): boolean;
getWidth(): number;
getZIndex(): number;
setLocation(location: Location): void;
setOptions(options: PushpinOptions): void;
toString(): string;
click: (eventArgs: MouseEventArgs) => void;
dblclick: (eventArgs: MouseEventArgs) => void;
drag: (object: Pushpin) => any;
dragend: (eventArgs: MouseEventArgs) => void;
dragstart: (eventArgs: MouseEventArgs) => void;
entitychanged: (object: { entity: Entity; }) => any;
mousedown: (eventArgs: MouseEventArgs) => void;
mouseout: (eventArgs: MouseEventArgs) => void;
mouseover: (eventArgs: MouseEventArgs) => void;
mouseup: (eventArgs: MouseEventArgs) => void;
rightclick: (eventArgs: MouseEventArgs) => void;
}
export enum EntityState {
highlighted,
none,
selected
}
export interface PushpinOptions {
anchor?: Point;
draggable?: boolean;
height?: number;
htmlContent?: string;
icon?: string;
infobox?: Infobox;
state?: EntityState;
text?: string;
textOffset?: Point;
typeName?: string;
visible?: boolean;
width?: number;
zIndex?: number;
}
export class TileLayer implements Entity {
constructor(options: TileLayerOptions);
getOpacty(): number;
getTileSource(projection: string): TileSource;
getZIndex(): number;
setOptions(options: TileLayerOptions): void;
toString(): string;
tiledownloadcomplete: () => void;
}
export class TileSource {
constructor(options: TileSourceOptions);
getHeight(): number;
getUriConstructor(): string;
getWidth(): string;
toString(): string;
}
export interface TileSourceOptions {
height?: number;
uriConstructor: string;
width?: number;
}
export interface TileLayerOptions {
animationDisplay?: AnimationVisibility;
downloadTimeout?: number;
mercator?: TileSource;
opacity?: number;
visible?: boolean;
zIndex?: number;
}
export enum AnimationVisibility {
auto,
hide,
show
}
export class Coordinates {
accuracy: number;
altitude: number;
altitudeAccuracy: number;
heading: number;
latitude: number;
longitude: number;
}
export class GeoLocationProvider {
constructor(map: Map);
addAccuracyCircle(center: Location, radiusInMeters: number, segments: number, options: PositionCircleOptions): void;
cancelCurrentRequest(): void;
getCurrentPosition(options?: PositionOptions): void;
removeAccuracyCircle(): void;
}
export interface PositionCircleOptions {
polygonOptions: PolygonOptions;
showOnMap: boolean;
}
export class PositionError {
errorCode: number;
internalError: string;
}
export interface ModuleOptions {
callback?: () => void;
styleURLS?: Array<string>;
culture?: string;
homeRegion?: string;
}
export function loadModule(moduleKey: string, options: ModuleOptions): void;
export function moduleLoaded(moduleKey: string): void;
export function registerModule(moduleKey: string, scriptUrl: string, options?: ModuleOptions): void;
}
+93
View File
@@ -0,0 +1,93 @@
/// <reference path="Microsoft.Maps.d.ts"/>
/// <reference path="Microsoft.Maps.AdvancedShapes.d.ts"/>
/// <reference path="Microsoft.Maps.Directions.d.ts"/>
/// <reference path="Microsoft.Maps.Search.d.ts"/>
/// <reference path="Microsoft.Maps.Themes.BingTheme.d.ts"/>
/// <reference path="Microsoft.Maps.Traffic.d.ts"/>
/// <reference path="Microsoft.Maps.VenueMaps.d.ts"/>
module BingMapsTests {
// An interactive set of Bing Maps AJAX control usages can be found at http://www.bingmapsportal.com/isdk/ajaxv7
// A full API description can be found at http://msdn.microsoft.com/en-us/library/gg427610.aspx
export class TestFixture {
public createMap(
// This key can be acquired at http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
bingMapsApiKey: string,
// This is the HTML container that the map will be drawn inside of
target: HTMLElement,
// These positions will be placed as pushpins onto the map
mapPositions: Array<Position>,
// This will fire if the geolocation fails and will pass the original target (parameter 2)
onFailure: (element: HTMLElement) => any) {
var self = this;
var map: Microsoft.Maps.Map;
navigator.geolocation.getCurrentPosition((position: Position) => {
var locations: Array<Microsoft.Maps.Location> = new Array<Microsoft.Maps.Location>();
var options: Microsoft.Maps.MapOptions;
function loadMap() {
options = {};
options.credentials = bingMapsApiKey;
options.enableClickableLogo = false;
options.enableSearchLogo = false;
options.showDashboard = false;
options.showScalebar = false;
options.center = self.toLocation(position);
options.zoom = 16;
options.mapTypeId = Microsoft.Maps.MapTypeId.road;
options.height = target.clientHeight;
options.width = target.clientWidth;
target.innerHTML = "";
map = new Microsoft.Maps.Map(target, options);
for (var i = 0; i < mapPositions.length; ++i) {
var mapPosition: Position = mapPositions[i];
var location: Microsoft.Maps.Location = self.createPushpin(map, mapPosition);
locations.push(location);
}
// Sets the view of the map to the smallest size that contains all of the
// specified locations (in this case the pusphin locations)
map.setView({ bounds: Microsoft.Maps.LocationRect.fromLocations(locations) });
}
if ((<any>window).Windows != undefined) {
// Running in Win8 app
Microsoft.Maps.loadModule("Microsoft.Maps.Map", { callback: loadMap });
} else {
// Running anywhere else
loadMap();
}
}, () => onFailure(target), { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
}
// Converts a standard HTML geolocation Position to a Location
private toLocation(position: Position): Microsoft.Maps.Location {
return new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude);
}
// Creates a pushpin on a specified map and returns the Location for potentially setting the map view
private createPushpin(map: Microsoft.Maps.Map, position: Position): Microsoft.Maps.Location {
var location: Microsoft.Maps.Location;
var pushpin: Microsoft.Maps.Pushpin;
location = this.toLocation(position);
pushpin = new Microsoft.Maps.Pushpin(location, null);
map.entities.push(pushpin);
return location;
}
}
}