Hexagon Geospatial
MENU

Smart M.App

Looking for answers in regards to M.Apps, M.App Exchange or M.App Studio? Smart M.App Tech Discussion board is where you can search, ask your questions and assist others by sharing your knowledge. Join the conversation, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 83
Registered: ‎07-17-2017

Add vector data to BI map legend

[ Edited ]

HI everybody,

 

I'd like to display a geojson file in my bi map and add it to the gsp.legend. My layer becomes registered but is not displayed. When I click the invisible button next to the layer name in the layer panel the following error accures: Cannot read property 'painter' of undefined. 

Is this because it is still not possible to add vector data in another way than as choropleth widget?

 

This is the code:

 

var geojson;
var itemID='03553f4d-d8be-4cad-b20e-68f368fef0de_2c9180825efefde101621af6764a05af';
var itemName='testgeojson';


gsp.m_app.utils.connection({
						path : 'api/v1/items/'+itemID+'/attachments/'+itemName+'.geojson.attachment',
						method : 'GET'
					}).then(function (response) { 
					        console.log(gsp.utils.deserialize(response.entity));
						geojson=gsp.utils.deserialize(response.entity);
					        addOutputToMap();
					    
						
					}).catch(function(err) {
						console.log(err);
					});
					
					
function addOutputToMap(){
    
   gsp.m_app.utils.connection({
						path : 'api/v1/items/'+itemID+'.json?profile=full',
						method : 'GET'
					}).then(function (response) { 
					    console.log(response.entity);
                            legendModel= {
                                            definitionName: "MAppPlatformGeoJson",
                                            url: geojson,
                                            name: "Layer1",
                                            id: "newLayer",
                                            bbox: response.entity.results[0].footprint.envelope.slice(0,4),
                                            bboxCrs: "EPSG:4326",
                                            supportedCrses: ["EPSG:4326"],
                                            style: {
                                                    display: "thematicLayer"
                                                    }
                                        };
                             gsp.legend.add(legendModel, function() {
                                                console.log("Registered layer");
                                            }, onError);
					});
  
}

function onError(e) {
    console.log("Something went wrong");
    console.log(e);
}

 

Frequent Contributor
Posts: 100
Registered: ‎10-16-2015

Re: Add vector data to BI map legend

I believe this would go wrong because 'url' doesn't contain a url, but the actual geojson data? 

I guess you'd have to use the path in util.connection instead.

 

I stubled upon this question because it's what I would like to do: add a layer giving some geojson data instead of a url. This doesn't seem possible?

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.