首页 / 浏览问题 / 云GIS / 问题详情
Geometry.Point中点的坐标是经纬度吗
17EXP 2019年06月03日

使用产品:iserver 8c  操作系统:win10 x64
数据类型: 文件型
问题详细描述:SuperMap.Geometry.Point()中点的坐标使用经纬度,之后使用SuperMap.Geometry.Polygon构建多边形,在地图上无法显示
问题重现步骤:

源代码如下:

for(var j=0;j<each_geometry.coordinates.length;++j){

//console.log(each_geometry.coordinates.length);//

each_coordinate=each_geometry.coordinates[j];

var points=[];

//console.log(each_coordinate.length);

for(var k=0;k<each_coordinate.length-1;++k){

var each_coordinates=each_coordinate[k];

//console.log(each_coordinates);

var point=new SuperMap.Geometry.Point(parseFloat(each_coordinates[0]),parseFloat(each_coordinates[1]));

//console.log(each_coordinates[0]);

//console.log(each_coordinates[1]);

points.push(point);

}

console.log(points);

var linearRings = new SuperMap.Geometry.LinearRing(points);

var polygon = new SuperMap.Geometry.Polygon([linearRings]);//geometry对象

var polyFeature = new SuperMap.Feature.Vector(polygon,null,style);

f.push(polyFeature);

}

1个回答

这个xy值是横坐标和纵坐标,和地图的坐标系对应就行。经纬度地图就用经纬度的值
5,668EXP 2019年06月03日
可是对应经纬度后在地图上无法显示呢?请问有什么解决办法吗?
添加完点把vector图层添加到map里了么  addTo(map)
使用animatorVector.addFeatures(f);,之后该怎么办呢?我是根据示例代码来的,演示时空数据,就是不知道错哪了,能麻烦您帮我看看吗?
host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090",
        url1 = host + "/iserver/services/map-world/rest/maps/World";
        init();
    function init() {
        //加载map控件
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
               new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })], units: "m"
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
        //初始化图层
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("China400", url1, {
            transparent: true,
            cacheEnabled: true
        }, {maxResolution: "auto"});
        //初始化动画矢量图层
        animatorVector = new SuperMap.Layer.AnimatorVector("Polygon", {smooth: false}, {
            //设置速度为每帧播放1小时的数据
            speed: 1,
            //开始时间为0点
            startTime: 0,
            //每秒渲染1次
            frameRate: 1,
            //结束时间为7点
            endTime: 7
        });
        layer.events.on({"layerInitialized": addLayer});
    }
    //添加图层
    function addLayer() {
        map.addLayers([layer, animatorVector]);
        map.setCenter(new SuperMap.LonLat(120, 34), 2);
        map.addControl(new SuperMap.Control.MousePosition());
        monitor();
    };
    //添加数据
    function monitor() {
        //初始化数据
        animatorVector.removeAllFeatures();
        //console.log(jiangsu05);
        features=jiangsu05.features;
        var f=[];
        //console.log(features);
        for(var i=0;i<5;++i){
            var each_geometry=features[i].geometry;
            //console.log(each_geometry);
           //找value确定颜色
            var style;
            var value=features[i].properties.value;
            //console.log(value);
            if(value>20 && value<30){
               style=style1;
            }
            else if(value>=30 && value<40){
               style=style2;

            }

            else if(value==42){

                style=style3;

            }

            else if(value==42||(value>42&&value<50)){

                style=style4;

            }

            else if(value==51||value==52){

                style=style5;

            }

            else if(value==53){

                style=style6;

            }

            else if(value>=61&&value<70){

                style=style7;

            }

            else{

                style=style8;

            }

            //找点

           // console.log(each_geometry.length);

            for(var j=0;j<each_geometry.coordinates.length;++j){

                //console.log(each_geometry.coordinates.length);//

                each_coordinate=each_geometry.coordinates[j];

                var points=[];

                //console.log(each_coordinate.length);

                for(var k=0;k<each_coordinate.length-1;++k){

                    var each_coordinates=each_coordinate[k];

                    //console.log(each_coordinates);

                    var point=new SuperMap.Geometry.Point(parseFloat(each_coordinates[0]),parseFloat(each_coordinates[1]));

                    //console.log(each_coordinates[0]);

                    //console.log(each_coordinates[1]);

                    points.push(point);

                }

                console.log(points);

                var linearRings = new SuperMap.Geometry.LinearRing(points);

                var polygon = new SuperMap.Geometry.Polygon([linearRings]);//geometry对象

                var polyFeature = new SuperMap.Feature.Vector(polygon,null,style);

                f.push(polyFeature);  

            }  

        }

        animatorVector.addFeatures(f);


 function addLayer() {
        map.addLayers([layer, animatorVector]);
        map.setCenter(new SuperMap.LonLat(120, 34), 2);
        map.addControl(new SuperMap.Control.MousePosition());
        monitor();
    };

你把这段里的monitor放到方法里的第一行看下

还是无法显示呢?我觉得我的代码没错呀怎们就显示不了了呢,我从idesktop里导出的json格式的面数据,然后提取各个点,构建多边形,就是无法显示呢?请问还有什么解决方法吗?
json解析了吗?
我没解析json,直接提取了里面的x、y坐标,构建点对象的方法不行吗?导出的json文件是geojson还是simplejson有关系吗?
您先看一下polygon这个是否是正确的,用vectorlayer显示一下这个图层看看能不能正确显示。现在这样看不出来中间某个对象是否出问题了

使用SuperMap.Layer.Vector能够显示但是改为SuperMap.Layer.AnimatorVector()就显示不出多边形了,请问是为什么呢?

设置一下featureid和time试一下,featureid设置成一样的值,然后time设置一下渐变的时间

加了之后并没有渐变的效果,就显示了两个图层,请问是为什么呢
你的TIME是怎么设置的
一个100,一个1000,请问这样不可以吗
var points2 = [

new SuperMap.Geometry.Point(-120, 54.142),

new SuperMap.Geometry.Point(-110, 40),

new SuperMap.Geometry.Point(-120, 25.857),

new SuperMap.Geometry.Point(-140, 25.857),

new SuperMap.Geometry.Point(-150, 40),

new SuperMap.Geometry.Point(-140, 54.142),

new SuperMap.Geometry.Point(-120, 54.142)

],

linearRings = new SuperMap.Geometry.LinearRing(points2),

region = new SuperMap.Geometry.Polygon([linearRings]);

var polygonVector1 = new SuperMap.Feature.Vector(region,{

FEATUREID:2,

TIME:100

}

);

var points3 = [

new SuperMap.Geometry.Point(-120, 50),

new SuperMap.Geometry.Point(-110, 30),

new SuperMap.Geometry.Point(-120, 20),

new SuperMap.Geometry.Point(-140, 20),

new SuperMap.Geometry.Point(-150, 40),

new SuperMap.Geometry.Point(-140, 50),

new SuperMap.Geometry.Point(-120, 50)

],

linearRings = new SuperMap.Geometry.LinearRing(points3),

region = new SuperMap.Geometry.Polygon([linearRings]);

var polygonVector2 = new SuperMap.Feature.Vector(region,{

FEATUREID:2,

TIME:1000

}

);

vector.addFeatures([polygonVector1,polygonVector2]);
你的vector传到的是AnimatorVector里还是vectorlayer里了?测试的话可以先把TIME设置为0,100.然后我这边用官网的范例测试了一下,传入到AnimatorVector里,只有在TIME都是0的时候会出现只出现两个面没有渐变的效果
vector = new SuperMap.Layer.Vector("vector"); vector的定义是这个,还是应该传入AnimatorVector?
官网的这个范例方便贴个链接给我看一下吗?我一直找不到是按照API文档来的
把这数据传入到AnimatorVector里图层不显示呢

http://iclient.supermap.io/examples/classic/editor.html#vizLayer_animatorBase

这个是那个官网的范例,之前是让测试看一下polygon能不能显示,所以是用vector这个图层去看,然后您说没问题就是polygon这个对象是正确的,然后就用原来的代码,把polygon那个传给animatorvector。设置TIME为100和1000的话一开始是看不到的,设置成0和100的话会从初始加载会出来第一个polygon的位置,然后到100的时候渐变到第二个polygon

...