UNPKG

google-maps-drawing-tools

Version:
56 lines (55 loc) 1.61 kB
/// <reference types="googlemaps" /> import Tool, { Shape, ToolId } from './tool'; export interface ManagerOptions { /** * Recommended to set here, but can also be set via `setMap`. */ map?: google.maps.Map; /** * Pass in your own `google.maps.Data` instance to put the drawings * on. */ data?: google.maps.Data; } export default class DrawingManager { map: any; data: google.maps.Data; /** * The currently selected tool. */ tool?: Tool; shapes: Shape[]; constructor(options?: ManagerOptions); /** * Change to a specified tool which will be used to draw on the map. * * @param toolId The identifier of the tool to change to */ changeTool(toolId: ToolId | null): Shape | undefined; /** * Removes a shape from the `shapes` array. * Also removes it from the `data` layer if the `feature` is present on the shape. * * @param shape The shape to remove */ removeShape(shape: Shape): void; /** * Adds a shape to the `shapes` array. If the shape contains a `feature`, then that * feature is added to the `data` layer. * * @param shape The shape to add */ addShape(shape: Shape): void; /** * Create a tool based on it's id. * * @param toolId The tool to create, by id */ createTool(toolId: ToolId | null): (Tool | undefined); /** * Show or hide the drawings by changing the map. * * @param map Google Map instance on which to show the drawings */ setMap(map: google.maps.Map | null): void; }