当前位置:网站首页>Openlayers ol ext: Transform object, rotate, stretch, zoom in
Openlayers ol ext: Transform object, rotate, stretch, zoom in
2022-07-25 03:06:00 【Gary_ Leong】

OpenLayers quote ol-ext:Transform Can be right Feature Enlarge the drawing 、 narrow 、 Move 、 rotate 、 Stretching and other operations , Very easy to use .
Code :
transformFeature() {
var _this = this
if (this.transform !== null || this.transform !== '') {
this.map.removeInteraction(this.transform)
}
this.editMenuStyle.height = '0px'
const transform = new Transform({
enableRotatedTransform: false,
addCondition: shiftKeyOnly,
hitTolerance: 2,
// Translate when click on feature
translateFeature: false,
// Can translate the feature
translate: true,
stretch: true,
scale: true,
rotate: true
})
var firstPoint = false
var startangle = 0
var d = [0, 0]
transform.on(['select'], function(e) {
if (firstPoint && e.features && e.features.getLength()) {
transform.setCenter(e.features.getArray()[0].getGeometry().getFirstCoordinate())
}
})
transform.on(['rotatestart', 'translatestart'], function(e) {
// Rotation
startangle = e.feature.get('angle') || 0
// Translation
d = [0, 0]
})
transform.on('rotating', function(e) {
// Set angle attribute to be used on style !
e.feature.set('angle', startangle - e.angle)
})
transform.on('translating', function(e) {
d[0] += e.delta[0]
d[1] += e.delta[1]
if (firstPoint) {
transform.setCenter(e.features.getArray()[0].getGeometry().getFirstCoordinate())
}
})
transform.on('scaling', function(e) {
if (firstPoint) {
transform.setCenter(e.features.getArray()[0].getGeometry().getFirstCoordinate())
}
})
transform.on(['rotateend', 'translateend', 'scaleend'], function(e) {
_this.editFeatureCoord(e.feature)
})
this.transform = transform
this.map.addInteraction(this.transform)
},
边栏推荐
- Dynamic planning of force buckle punch in summary
- mysql_ Record the executed SQL
- Details of happens before rules
- Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development
- How to use blender to make 360 degree panorama and panoramic video?
- [Kali's sshd service is enabled]
- C: wechat chat software instance (wpf+websocket+webapi+entityframework)
- Canvas record
- Print the common part of two ordered linked lists
- SQL Server 2022 installation
猜你喜欢

JS foundation -- task queue and event loop

List title of force buckle summary

Tp5.1 include include files (reference public files)

JS written test question -- deep copy of object

Wechat sports field reservation of the finished works of the applet graduation project (7) mid-term inspection report

Mark down learning

6.0 cancellation of member registration verification code

Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development

Eslint error

Beginners must see the markdown User Guide
随机推荐
Win10 -- open the hosts file as an administrator
mysql_ Backup restore_ Specify table_ Backup table_ Restore table_ innobackup
List title of force buckle summary
[stm32f130rct6] idea and code of ultrasonic ranging module
Several dpdk control frameworks
Wechat H5 record
JS written test question -- prototype, new, this comprehensive question
If there is a segment in the encryption field, are you "bronze" or "King"?
Review all frames before sum of SSM frames
SQL recursive follow-up
Riotboard development board series notes (6) -- buildreoot building system image
JS written test question -- promise, setTimeout, task queue comprehensive question
Color space (1) - RGB
Edit mathematical formulas in markdown
Dc-1-practice
The file in scanpy1.9.1 cannot be read in scanpy1.7.2. The problem is solved
Wechat sports field reservation of the finished works of the applet graduation project (5) assignment
Physical experiment simulation
Node queries the path of all files (files or folders) named filename under the target directory
Unity refers to a variable in another class (its own instance)