🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@maptalks/transform-control

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maptalks/transform-control

a plugin to control model's translate、rotation and scale

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
2.2K
32.51%
Maintainers
1
Weekly downloads
 
Created
Source

maptalks.TransformControl

NPM Version

Usage

transform-control a plugin to control model's translate、rotation and scale.

Install

  • Install with npm: npm install @maptalks/transform-control.
  • Use unpkg CDN: https://unpkg.com/@maptalks/transform-control/dist/transform-control.js

Vanilla Javascript

<script type="text/javascript" src="../maptalks.transform-control.js"></script>
<script>
var map = new maptalks.Map("map",{
    center : [0, 0],
    zoom   :  15
});
var transformControl = new maptalks.TransformControl();
transformControl.addTo(map);
transformControl.on('transforming', e => {
    //get translate、rotation、scale
    const translate = e.translate;
    const rotation = e.rotation;
    const scale = e.scale;
});
</script>

ES6

import TransfromControl from '@maptalks/transform-control';

const map = new maptalks.Map("map",{
    center : [0, 0],
    zoom   :  15
});
const transformControl = new maptalks.TransformControl();
transformControl.addTo(map);
transformControl.on('transforming', e => {
    //get translate、rotation、scale
    const translate = e.translate;
    const rotation = e.rotation;
    const scale = e.scale;
});

API

  • Class : TransformControl(inherited from maptalks.Eventable)

    transform control's constructor.

    Method : new TransformControl(options)

    ParameterTypeDefaultDescription
    idStringtransform control's id
    optionsObjectnullconstruct options

    Method : addTo(map)

    add the control to a map

    ParameterTypeDefaultDescription
    mapmaptalks.Mapa map to add

    returns :
    TransformControl: this

    Method : remove()

    remove the control from map

    Method : setMode(mode)

    set the mode of control

    ParameterTypeDefaultDescription
    modeStringtranslatetranslaterotation and scale alternative

    Method : getMode()

    get the mode of control

    returns :
    String: current mode of transform control

    Method : transform(target)

    specify a target to transform

    ParameterTypeDefaultDescription
    targetGLTFMarker | Meshnullthe target to transform

    Method : getTransformTarget()

    get the current tranforming target

    returns :
    Object: the transforming target object

    Method : enable()

    enable the control

    returns :
    TransformControl: return this

    Method : disable()

    disable the control, when disable the control, it will be not available TransformControl: return this

    Method : isEnbale()

    whether the control is enable Boolean: true or false

FAQs

Package last updated on 29 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts