From 9001491e046ab067f8e58558de067d2075f177ae Mon Sep 17 00:00:00 2001 From: MaShizhen <2473872761@qq.com> Date: Mon, 12 Mar 2018 19:41:00 +0800 Subject: [PATCH] centerAndZoom(city: string): void --- .../baidumap-web-sdk-tests.ts | 45 +-- types/baidumap-web-sdk/baidumap.core.d.ts | 261 +++++++++--------- 2 files changed, 155 insertions(+), 151 deletions(-) diff --git a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts index 8ac6457975..9954fd487c 100644 --- a/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts +++ b/types/baidumap-web-sdk/baidumap-web-sdk-tests.ts @@ -1,24 +1,27 @@ import "./index" namespace BMapTests { - export class TestFixture { - //document: http://lbsyun.baidu.com/index.php?title=jspopular - public createMap(container: string | HTMLElement) { - navigator.geolocation.getCurrentPosition((position: Position) => { - const point = new BMap.Point(position.coords.longitude, position.coords.latitude); - const map = new BMap.Map(container); - map.centerAndZoom(point, 15); - }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); - } - public addControl(map: BMap.Map) { - map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); - map.addControl(new BMap.NavigationControl()); - map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); - map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); - } - public addMarker(map: BMap.Map, point: BMap.Point) { - const marker = new BMap.Marker(point); - map.addOverlay(marker); - marker.setAnimation(BMAP_ANIMATION_BOUNCE); - } - } + export class TestFixture { + //document: http://lbsyun.baidu.com/index.php?title=jspopular + public createMap(container: string | HTMLElement) { + navigator.geolocation.getCurrentPosition((position: Position) => { + const point = new BMap.Point(position.coords.longitude, position.coords.latitude); + const map = new BMap.Map(container); + map.centerAndZoom(point, 15); + }, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); + } + public addControl(map: BMap.Map) { + map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT })); + map.addControl(new BMap.NavigationControl()); + map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] })); + map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT })); + } + public addMarker(map: BMap.Map, point: BMap.Point) { + const marker = new BMap.Marker(point); + map.addOverlay(marker); + marker.setAnimation(BMAP_ANIMATION_BOUNCE); + } + public create_map(map: BMap.Map, city: string) { + map.centerAndZoom(city); + } + } } diff --git a/types/baidumap-web-sdk/baidumap.core.d.ts b/types/baidumap-web-sdk/baidumap.core.d.ts index 24d1aed9f0..98782a1c1e 100644 --- a/types/baidumap-web-sdk/baidumap.core.d.ts +++ b/types/baidumap-web-sdk/baidumap.core.d.ts @@ -20,135 +20,136 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI /// /// declare namespace BMap { - class Map { - constructor(container: string | HTMLElement, opts?: MapOptions) - enableDragging(): void - disableDragging(): void - enableScrollWheelZoom(): void - disableScrollWheelZoom(): void - enableDoubleClickZoom(): void - disableDoubleClickZoom(): void - enableKeyboard(): void - disableKeyboard(): void - enableInertialDragging(): void - disableInertialDragging(): void - enableContinuousZoom(): void - disableContinuousZoom(): void - enablePinchToZoom(): void - disablePinchToZoom(): void - enableAutoResize(): void - disableAutoResize(): void - setDefaultCursor(cursor: string): void - getDefaultCursor(): string - setDraggingCursor(cursor: string): void - getDraggingCursor(): string - setMinZoom(zoom: number): void - setMaxZoom(zoom: number): void - setMapStyle(mapStyle: MapStyle): void - setPanorama(pano: Panorama): void - disable3DBuilding(): void - getBounds(): Bounds - getCenter(): Point - getDistance(start: Point, end: Point): number - getMapType(): MapType - getSize(): Size - getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport - getZoom(): number - getPanorama(): Panorama - centerAndZoom(center: Point, zoom: number): void - panTo(center: Point, opts?: PanOptions): void - panBy(x: number, y: number, opts?: PanOptions): void - reset(): void - setCenter(center: Point | string): void - setCurrentCity(city: string): void - setMapType(mapType: MapType): void - setViewport(view: Point[], viewportOptions?: ViewportOptions): void - setZoom(zoom: number): void - highResolutionEnabled(): boolean - zoomIn(): void - zoomOut(): void - addHotspot(hotspot: Hotspot): void - removeHotspot(hotspot: Hotspot): void - clearHotspots(): void - addControl(control: Control): void - removeControl(control: Control): void - getContainer(): HTMLElement - addContextMenu(menu: ContextMenu): void - removeContextMenu(menu: ContextMenu): void - addOverlay(overlay: Overlay): void - removeOverlay(overlay: Overlay): void - clearOverlays(): void - openInfoWindow(infoWnd: InfoWindow, point: Point): void - closeInfoWindow(): void - pointToOverlayPixel(point: Point): Pixel - overlayPixelToPoint(pixel: Pixel): Point - getInfoWindow(): InfoWindow - getOverlays(): Overlay[] - getPanes(): MapPanes - addTileLayer(tileLayer: TileLayer): void - removeTileLayer(tilelayer: TileLayer): void - getTileLayer(mapType: string): TileLayer - pixelToPoint(pixel: Pixel): Point - pointToPixel(point: Point): Pixel - onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmaptypechange: (event: { type: string, target: any }) => void - onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void - onmouseover: (event: { type: string, target: any }) => void - onmouseout: (event: { type: string, target: any }) => void - onmovestart: (event: { type: string, target: any }) => void - onmoving: (event: { type: string, target: any }) => void - onmoveend: (event: { type: string, target: any }) => void - onzoomstart: (event: { type: string, target: any }) => void - onzoomend: (event: { type: string, target: any }) => void - onaddoverlay: (event: { type: string, target: any }) => void - onaddcontrol: (event: { type: string, target: any }) => void - onremovecontrol: (event: { type: string, target: any }) => void - onremoveoverlay: (event: { type: string, target: any }) => void - onclearoverlays: (event: { type: string, target: any }) => void - ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onaddtilelayer: (event: { type: string, target: any }) => void - onremovetilelayer: (event: { type: string, target: any }) => void - onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void - onresize: (event: { type: string, target: any, size: Size }) => void - onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void - onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void - ontilesloaded: (event: { type: string, target: any }) => void - ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void - } - interface PanOptions { - noAnimation?: boolean - } - interface MapOptions { - minZoom?: number - maxZoom?: number - mapType?: MapType - enableHighResolution?: boolean - enableAutoResize?: boolean - enableMapClick?: boolean - } - interface Viewport { - center: Point - zoom: number - } - interface ViewportOptions { - enableAnimation?: boolean - margins?: number[] - zoomFactor?: number - delay?: number - } - type APIVersion = number - interface MapStyle { - features: any[] - style: string - } + class Map { + constructor(container: string | HTMLElement, opts?: MapOptions) + enableDragging(): void + disableDragging(): void + enableScrollWheelZoom(): void + disableScrollWheelZoom(): void + enableDoubleClickZoom(): void + disableDoubleClickZoom(): void + enableKeyboard(): void + disableKeyboard(): void + enableInertialDragging(): void + disableInertialDragging(): void + enableContinuousZoom(): void + disableContinuousZoom(): void + enablePinchToZoom(): void + disablePinchToZoom(): void + enableAutoResize(): void + disableAutoResize(): void + setDefaultCursor(cursor: string): void + getDefaultCursor(): string + setDraggingCursor(cursor: string): void + getDraggingCursor(): string + setMinZoom(zoom: number): void + setMaxZoom(zoom: number): void + setMapStyle(mapStyle: MapStyle): void + setPanorama(pano: Panorama): void + disable3DBuilding(): void + getBounds(): Bounds + getCenter(): Point + getDistance(start: Point, end: Point): number + getMapType(): MapType + getSize(): Size + getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport + getZoom(): number + getPanorama(): Panorama + centerAndZoom(center: Point, zoom: number): void + centerAndZoom(city: string): void + panTo(center: Point, opts?: PanOptions): void + panBy(x: number, y: number, opts?: PanOptions): void + reset(): void + setCenter(center: Point | string): void + setCurrentCity(city: string): void + setMapType(mapType: MapType): void + setViewport(view: Point[], viewportOptions?: ViewportOptions): void + setZoom(zoom: number): void + highResolutionEnabled(): boolean + zoomIn(): void + zoomOut(): void + addHotspot(hotspot: Hotspot): void + removeHotspot(hotspot: Hotspot): void + clearHotspots(): void + addControl(control: Control): void + removeControl(control: Control): void + getContainer(): HTMLElement + addContextMenu(menu: ContextMenu): void + removeContextMenu(menu: ContextMenu): void + addOverlay(overlay: Overlay): void + removeOverlay(overlay: Overlay): void + clearOverlays(): void + openInfoWindow(infoWnd: InfoWindow, point: Point): void + closeInfoWindow(): void + pointToOverlayPixel(point: Point): Pixel + overlayPixelToPoint(pixel: Pixel): Point + getInfoWindow(): InfoWindow + getOverlays(): Overlay[] + getPanes(): MapPanes + addTileLayer(tileLayer: TileLayer): void + removeTileLayer(tilelayer: TileLayer): void + getTileLayer(mapType: string): TileLayer + pixelToPoint(pixel: Pixel): Point + pointToPixel(point: Point): Pixel + onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmaptypechange: (event: { type: string, target: any }) => void + onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void + onmouseover: (event: { type: string, target: any }) => void + onmouseout: (event: { type: string, target: any }) => void + onmovestart: (event: { type: string, target: any }) => void + onmoving: (event: { type: string, target: any }) => void + onmoveend: (event: { type: string, target: any }) => void + onzoomstart: (event: { type: string, target: any }) => void + onzoomend: (event: { type: string, target: any }) => void + onaddoverlay: (event: { type: string, target: any }) => void + onaddcontrol: (event: { type: string, target: any }) => void + onremovecontrol: (event: { type: string, target: any }) => void + onremoveoverlay: (event: { type: string, target: any }) => void + onclearoverlays: (event: { type: string, target: any }) => void + ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onaddtilelayer: (event: { type: string, target: any }) => void + onremovetilelayer: (event: { type: string, target: any }) => void + onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void + onresize: (event: { type: string, target: any, size: Size }) => void + onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void + onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void + ontilesloaded: (event: { type: string, target: any }) => void + ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void + } + interface PanOptions { + noAnimation?: boolean + } + interface MapOptions { + minZoom?: number + maxZoom?: number + mapType?: MapType + enableHighResolution?: boolean + enableAutoResize?: boolean + enableMapClick?: boolean + } + interface Viewport { + center: Point + zoom: number + } + interface ViewportOptions { + enableAnimation?: boolean + margins?: number[] + zoomFactor?: number + delay?: number + } + type APIVersion = number + interface MapStyle { + features: any[] + style: string + } } declare const BMAP_API_VERSION: BMap.APIVersion \ No newline at end of file