Constructor
new TextLayer()
Example
//构造地图对象
var map = new GeoGlobe.Map({
style: Cfg.style,
container: 'map',
zoom: 18,
bearing: -47,
pitch: 45,
units: "degrees",
center: [114.26734490525155, 30.594607628267966]
});
//构造THREE可视化图层
var threebox = new GeoGlobe.Visuals.Three();
//绑定鼠标点击事件
threebox.on('overlayerclick', function(e){
var xyz = threebox.unprojectFromWorld(e.param.pickedInfos[0].point);
alert(e.param.info.userData.attributes.OriginalData.properties.name + '\n经纬度及高程:' + xyz);
});
//绑定鼠标移动事件
threebox.on('overlayerhover', function(e){
console.info(e);
});
//添加到地图中
threebox.addTo(map);
//构造文本图层
var textLayer = new GeoGlobe.Visuals.Three.TextLayer({
id: 'text in 3D',
data: [
{"type":"Feature","properties":{"name": "一号文本","height": 40, "text": "我是文本Q1", color: "rgb(255, 120, 0)"},"geometry":{"type":"Point","coordinates":[114.267589714434,30.593727684842285]}},
],
visible: true,
opacity: 1,
scale: 1,
size: 10,
thickness: 3,
curveSegments: 4,
fontURL: '../../fonts/SimHei_Regular.json', //简体
getGeometry: function(geometry, data){
geometry.rotateX((90/360)*2*Math.PI);
geometry.rotateZ((180/360)*2*Math.PI);
return geometry;
},
});
//添加到THREE图层
textLayer.addTo(threebox);
//绘制
threebox.render();
Members
curveSegments :Int
- Default Value:
- 12
字体曲面光滑度
Type:
- Int
data :Array
数据
Type:
- Array
Example
[{
"type":"Feature",
"properties":{
"id": 100001,
"name":"1号视频",
"text":"我是文本1",
"height":30,
"color": "rgb(255, 120, 0)"
},
"geometry":{
"type":"Point",
"coordinates": [114.20257245367856, 30.773372078561778]
}
}]
fontURL :String
- Default Value:
- ''
字体资源路径
Type:
- String
id :String
- Default Value:
- '1'
图层id
Type:
- String
opacity :Float
- Default Value:
- 1.0
透明度 0-1
Type:
- Float
size :Int
- Default Value:
- 100
字体大小
Type:
- Int
thickness :Int
- Default Value:
- 50
字体厚度
Type:
- Int
visible :Boolean
- Default Value:
- true
可见性
Type:
- Boolean
Methods
addTo(three)
关联Three
Parameters:
Name | Type | Description |
---|---|---|
three |
GeoGlobe.Visuals.Three |
getColor(data) → {String}
颜色GET属性
Parameters:
Name | Type | Description |
---|---|---|
data |
Feature | geojson中的一个Feature |
Returns:
color - 颜色值
- Type
- String
getGeometry(geometry, data) → {Geometry}
几何对象GET属性
Parameters:
Name | Type | Description |
---|---|---|
geometry |
Geometry | THREE.Geometry |
data |
Feature | geojson中的一个Feature |
Returns:
geometry - 可对geometry平移旋转缩放后的
- Type
- Geometry
getPosition(data) → {Array}
地理位置GET属性
Parameters:
Name | Type | Description |
---|---|---|
data |
Feature | geojson中的一个Feature |
Returns:
point - [x,y,z]
- Type
- Array
getText(data) → {String}
文本GET属性
Parameters:
Name | Type | Description |
---|---|---|
data |
Feature | geojson中的一个Feature |
Returns:
text - data.properties.text
- Type
- String
remove()
从父对象中移除自己
render()
绘制