mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Added NgMap definitions (#10642)
* Added NgMap definitions * Removed MarkerLabel from label * Fixed url to DefinitelyTyped repository * Changed module to namespace. * Reflect changes also to ng-map-tests. * Renamed folders, files and module for naming conventions * Changed reference path in tests to reflect recent naming changes.
This commit is contained in:
committed by
Masahiro Wakame
parent
2a6a1dc8e6
commit
fa33748396
25
ngmap/ngmap-tests.ts
Normal file
25
ngmap/ngmap-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference path="ngmap.d.ts" />
|
||||
class NgMapTestController {
|
||||
constructor(public $scope: ng.IScope, public $window: ng.IWindowService, public NgMap: angular.map.INgMap) {
|
||||
this.showMap();
|
||||
}
|
||||
|
||||
public showMap() {
|
||||
this.NgMap.getMap().then(function(map) {
|
||||
console.log(map.getCenter());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var app = angular.module('angularLocalStorageTests', ['ngMap']);
|
||||
|
||||
app.config(function(NgMapProvider: angular.map.INgMapProvider) {
|
||||
NgMapProvider.setDefaultOptions({
|
||||
marker: {
|
||||
optimized: false
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.controller('testCtrl', ['$scope', '$window', 'ngMap',
|
||||
($scope: ng.IScope, $window: ng.IWindowService, NgMap: angular.map.INgMap) => new NgMapTestController($scope, $window, NgMap)]);
|
||||
148
ngmap/ngmap.d.ts
vendored
Normal file
148
ngmap/ngmap.d.ts
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
// Type definitions for angularjs-google-maps v1.17.3
|
||||
// Project: https://github.com/allenhwkim/angularjs-google-maps
|
||||
// Definitions by: Niko Kovačič <https://github.com/nkovacic>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../googlemaps/google.maps.d.ts" />
|
||||
|
||||
declare module "ngmap" {
|
||||
let _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
declare namespace angular.map {
|
||||
interface IGetMapOptions {
|
||||
id?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
interface INgMapOptions {
|
||||
marker: {
|
||||
/**
|
||||
* The offset from the marker's position to the tip of an InfoWindow
|
||||
* that has been opened with the marker as anchor.
|
||||
*/
|
||||
anchorPoint?: google.maps.Point;
|
||||
/** Which animation to play when marker is added to a map. */
|
||||
animation?: google.maps.Animation;
|
||||
/**
|
||||
* If true, the marker receives mouse and touch events.
|
||||
* @default true
|
||||
*/
|
||||
clickable?: boolean;
|
||||
/** Mouse cursor to show on hover. */
|
||||
cursor?: string;
|
||||
/**
|
||||
* If true, the marker can be dragged.
|
||||
* @default false
|
||||
*/
|
||||
draggable?: boolean;
|
||||
/**
|
||||
* Icon for the foreground.
|
||||
* If a string is provided, it is treated as though it were an Icon with the string as url.
|
||||
* @type {(string|Icon|Symbol)}
|
||||
*/
|
||||
icon?: string|google.maps.Icon|google.maps.Symbol;
|
||||
/**
|
||||
* Adds a label to the marker. The label can either be a string, or a MarkerLabel object.
|
||||
* Only the first character of the string will be displayed.
|
||||
* @type {string}
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Map on which to display Marker.
|
||||
* @type {(Map|StreetViewPanorama)}
|
||||
*
|
||||
*/
|
||||
map?: google.maps.Map|google.maps.StreetViewPanorama;
|
||||
/** The marker's opacity between 0.0 and 1.0. */
|
||||
opacity?: number;
|
||||
/**
|
||||
* Optimization renders many markers as a single static element.
|
||||
* Optimized rendering is enabled by default.
|
||||
* Disable optimized rendering for animated GIFs or PNGs, or when each
|
||||
* marker must be rendered as a separate DOM element (advanced usage
|
||||
* only).
|
||||
*/
|
||||
optimized?: boolean;
|
||||
/** Image map region definition used for drag/click. */
|
||||
shape?: google.maps.MarkerShape;
|
||||
/** Rollover text. */
|
||||
title?: string;
|
||||
/** If true, the marker is visible. */
|
||||
visible?: boolean;
|
||||
/**
|
||||
* All markers are displayed on the map in order of their zIndex,
|
||||
* with higher values displaying in front of markers with lower values.
|
||||
* By default, markers are displayed according to their vertical position on screen,
|
||||
* with lower markers appearing in front of markers further up the screen.
|
||||
*/
|
||||
zIndex?: number;
|
||||
}
|
||||
}
|
||||
|
||||
interface IObserveAndSetFunc {
|
||||
(val: any): void;
|
||||
}
|
||||
|
||||
interface INgMap {
|
||||
/**
|
||||
* Add map to pool
|
||||
* @param {Function | any[]} mapCtrl Map controller
|
||||
*/
|
||||
addMap(mapCtrl: Function | any[]): void;
|
||||
/**
|
||||
* Delete map from pool
|
||||
* @param {Function | any[]} mapCtrl Map controller optional. Defaults to last
|
||||
* controller in pool
|
||||
*/
|
||||
deleteMap(mapCtrl?: Function | any[]): void;
|
||||
/**
|
||||
* Get map coordinates from address.
|
||||
* @param {string} address Use 'current' to get users location
|
||||
* @param {PositionOptions} options optional
|
||||
* @return {angular.IPromise<google.maps.LatLng>} Latitude ang longitude of the address
|
||||
*/
|
||||
getGeoLocation(address: string, options?: PositionOptions): angular.IPromise<google.maps.LatLng>
|
||||
/**
|
||||
* Get map from the pool of all shown maps.
|
||||
* @param {IGetMapOptions} options optional
|
||||
* @return {angular.IPromise<google.maps.Map>} promise
|
||||
*/
|
||||
getMap(options?: IGetMapOptions): angular.IPromise<google.maps.Map>
|
||||
/**
|
||||
* Initialize map from mapId or the current first shown map
|
||||
* @param {string} mapId id of the map. default 0
|
||||
* @return {google.maps.Map} map
|
||||
*/
|
||||
initMap(mapId?: string): google.maps.Map;
|
||||
/**
|
||||
* Observe attribute
|
||||
* @param {string} attrName attribute name
|
||||
* @param {Object} object a Google maps object to be changed
|
||||
* @return {IObserveAndSetFunc} attribute obvserve function
|
||||
*/
|
||||
observeAndSet(attrName: string, object: Object): IObserveAndSetFunc;
|
||||
/**
|
||||
* Set display, width, height of map container element
|
||||
* @param {HTMLElement} el map container element
|
||||
*/
|
||||
setStyle(el: HTMLElement): void;
|
||||
}
|
||||
|
||||
interface INgMapProvider {
|
||||
/**
|
||||
* @param {Hash} options
|
||||
* @example
|
||||
* app.config(function(NgMapProvider) {
|
||||
* NgMapProvider.setDefaultOptions({
|
||||
* marker: {
|
||||
* optimized: false
|
||||
* }
|
||||
* });
|
||||
* });
|
||||
*/
|
||||
setDefaultOptions(options: INgMapOptions): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user