Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TagComponent

class

TagComponent

classdesc

Component for showing and editing tags with different geometries composed from 2D basic image coordinates (see the Viewer class documentation for more information about coordinate systems).

The add method is used for adding new tags or replacing tags already in the set. Tags are removed by id.

If a tag already in the set has the same id as one of the tags added, the old tag will be removed and the added tag will take its place.

The tag component mode can be set to either be non interactive or to be in creating mode of a certain geometry type.

The tag properties can be updated at any time and the change will be visibile immediately.

Tags are only relevant to a single image because they are based on 2D basic image coordinates. Tags related to a certain image should be removed when the viewer is moved to another node.

To retrive and use the tag component

example
var viewer = new Mapillary.Viewer(
    "<element-id>",
    "<client-id>",
    "<my key>",
    { component: { tag: true } });

var tagComponent = viewer.getComponent("tag");

Hierarchy

Index

Events

Static creategeometryend

creategeometryend: string = "creategeometryend"

Event fired when an interaction to create a geometry ends.

description

A create interaction can by a geometry being created or by the creation being aborted.

type

{TagComponent} Tag component.

example
tagComponent.on("creategeometryend", function(component) {
    console.log(component);
});

Static creategeometrystart

creategeometrystart: string = "creategeometrystart"

Event fired when an interaction to create a geometry starts.

description

A create interaction starts when the first vertex is created in the geometry.

type

{TagComponent} Tag component.

example
tagComponent.on("creategeometrystart", function(component) {
    console.log(component);
});

Static geometrycreated

geometrycreated: string = "geometrycreated"

Event fired when a geometry has been created.

type

{Geometry} Created geometry.

example
tagComponent.on("geometrycreated", function(geometry) {
    console.log(geometry);
});

Static modechanged

modechanged: string = "modechanged"

Event fired when the create mode is changed.

type

{TagMode} Tag mode

example
tagComponent.on("modechanged", function(mode) {
    console.log(mode);
});

Static tagschanged

tagschanged: string = "tagschanged"

Event fired when the tags collection has changed.

type

{TagComponent} Tag component.

example
tagComponent.on("tagschanged", function(component) {
    console.log(component.getAll());
});

Properties

Static componentName

componentName: string = "tag"
inheritdoc

Accessors

activated

  • get activated(): boolean

defaultConfiguration

name

  • get name(): string
  • Get name.

    description

    The name of the component. Used when interacting with the component through the Viewer's API.

    Returns string

Methods

activate

add

  • add(tags: Tag[]): void
  • Add tags to the tag set or replace tags in the tag set.

    description

    If a tag already in the set has the same id as one of the tags added, the old tag will be removed the added tag will take its place.

    example

    tagComponent.add([tag1, tag2]);

    Parameters

    • tags: Tag[]

      Tags to add.

    Returns void

changeMode

  • Change the current tag mode.

    description

    Change the tag mode to one of the create modes for creating new geometries.

    fires

    TagComponent#modechanged

    example

    tagComponent.changeMode(Mapillary.TagComponent.TagMode.CreateRect);

    Parameters

    Returns void

configure

deactivate

  • deactivate(): void

fire

  • fire(eventType: string, data: any): void
  • Parameters

    • eventType: string
    • data: any

    Returns void

get

  • get(tagId: string): Tag
  • Returns the tag in the tag set with the specified id, or undefined if the id matches no tag.

    example

    var tag = tagComponent.get("tagId");

    Parameters

    • tagId: string

      Id of the tag.

    Returns Tag

getAll

  • getAll(): Tag[]

getTagIdsAt

  • getTagIdsAt(pixelPoint: number[]): when.Promise<string[]>
  • Returns an array of tag ids for tags that contain the specified point.

    description

    The pixel point must lie inside the polygon or rectangle of an added tag for the tag id to be returned. Tag ids for tags that do not have a fill will also be returned if the point is inside the geometry of the tag. Tags with point geometries can not be retrieved.

    No tag ids will be returned for polygons rendered in cropped panoramas or rectangles rendered in panoramas.

    Notice that the pixelPoint argument requires x, y coordinates from pixel space.

    With this function, you can use the coordinates provided by mouse events to get information out of the tag component.

    If no tag at exist the pixel point, an empty array will be returned.

    example
    tagComponent.getTagIdsAt([100, 100])
        .then((tagIds) => { console.log(tagIds); });

    Parameters

    • pixelPoint: number[]

      Pixel coordinates on the viewer element.

    Returns when.Promise<string[]>

    Ids of the tags that contain the specified pixel point.

has

  • has(tagId: string): boolean
  • Check if a tag exist in the tag set.

    example

    var tagExists = tagComponent.has("tagId");

    Parameters

    • tagId: string

      Id of the tag.

    Returns boolean

off

  • off(eventType: string, fn: any): void
  • Unsubscribe from an event by its name.

    Parameters

    • eventType: string

      The name of the event to subscribe to.

    • fn: any

      The handler to remove.

    Returns void

on

  • on(eventType: string, fn: any): void
  • Subscribe to an event by its name.

    Parameters

    • eventType: string

      The name of the event to subscribe to.

    • fn: any

      The handler called when the event occurs.

    Returns void

remove

  • remove(tagIds: string[]): void
  • Remove tags with the specified ids from the tag set.

    example

    tagComponent.remove(["id-1", "id-2"]);

    Parameters

    • tagIds: string[]

      Ids for tags to remove.

    Returns void

removeAll

  • removeAll(): void

Generated using TypeDoc