jiwenqiang

第 13 位会员

会员
个人信息
  • 加入于 2018-08-10 17:38:58
  • 最后登录时间 6年前
个人成就
  • 发表文章次数 1
  • 发布回复次数 2
  • 个人主页浏览次数 27
Cesium怎么让网格有经纬度显示6年前

你可以重写cesium里面的requestImage方法。 var tile_lay = new Cesium.TileCoordinatesImageryProvider({

tilingScheme: new Cesium.GeographicTilingScheme()

}); tile_lay.requestImage = function(x,y,level){

var canvas = document.createElement('canvas');
canvas.width = 256;
canvas.height = 256;
var context = canvas.getContext('2d');
context.strokeStyle = "rgba(192,192,192,0.7)";
context.lineWidth = 1;
context.strokeRect(0, 0, 256, 256);
var label = zxy2TileKey(level,x,y); //label里面放需要显示的文字
context.font = 'bold 6px Arial';
context.fillStyle = "rgba(255, 255, 255, 0.6)";
context.textAlign = 'center';
context.fillText(label, 124, 124);
return canvas;

}; viewer.scene.imageryLayers.addImageryProvider(grid_lay);

自定义标注后,点击怎么获取到它的值,大佬们知道吗6年前

var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
var scene = viewer.scene
var billboard
handler.setInputAction(function(click){
    var cartesian = viewer.camera.pickEllipsoid(click.position, viewer.scene.globe.ellipsoid)
    if(cartesian){
        var pickdObject = scene.pick(click.position)
        var position = viewer.camera.pickEllipsoid(click.position)
        if(Cesium.defined(pickdObject)){
			//根据点击对象的id删除该对象
            viewer.entities.getById(pickdObject.id._id).show = false //隐藏标记
        }else{
            var cartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(position)
            var lng = Cesium.Math.toDegrees(cartographic.longitude).toFixed(4) //经纬度
            var lat = Cesium.Math.toDegrees(cartographic.latitude).toFixed(4)
            billboard = viewer.entities.add({
                position: Cesium.Cartesian3.fromDegrees(lng, lat),
                billboard: {
                    image: "img/placeMarker.png",
                    pixelOffset: new Cesium.Cartesian2(0, 0),
                    eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
                    horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                    verticalOrigin: Cesium.VerticalOrigin.BOTTOM
                }
            });
        }
    }

},Cesium.ScreenSpaceEventType.LEFT_CLICK)

Your Site Analytics