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
Occasional Contributor
Posts: 8
Registered: ‎10-03-2017

Display of GeoJson polygon in map does not work

Hello everyone,

 

I am trying to display a geojson polygon in the way that points (gsp.map.pin.add) are displayed in a map (not custom made). 

 

    gsp.map.pin.add({
        geojson: { "type": "Point", "coordinates":[-5, 51.5]}
    });

 

I already tried it in a custom map an it worked just fine like this:

 

 

var polygon = {
"type": "Feature",},
"geometry": {"type": "Polygon","coordinates": [
[[11.513018091060982,48.125175965221125],

[11.513357732183717,48.125352727775422],

[11.513741239622414,48.125458785307991],
[11.51416861337707,48.125494137818855],
[11.515516534114973,48.125494137818855],
[11.515957935262129,48.125516496709913],
[11.516383524878329,48.1255835733831],
[11.516793302963571,48.125695367838425],
....
[11.50857953200364,48.122212598393538],
[11.513018091060982,48.125175965221125]]]}};
var geojsonLayer = new L.GeoJSON(polygon);
map.addLayer(geojsonLayer);

and looks like this in the custom map panel:

Polygoninmap.PNG

 

How can i receive the same result in an non custom map? 

 

Thanks in advance!

 

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: Display of GeoJson polygon in map does not work

Hi Stefanie,

 

What do you actually mean by a custom map? Are you referencing to Map vs. Custom panel?

 

Thanks,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 8
Registered: ‎10-03-2017

Re: Display of GeoJson polygon in map does not work

Hey Jan,

 

I figured it out how to do display a polygon in the custom panel when i create a map manually.

 

But if I’m using the map option (See attachments: map) I don’t know how to display a geojson polygon. So my question is how to display a polygon in the map.

 

Thanks

Stefanie

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: Display of GeoJson polygon in map does not work

[ Edited ]

Hi Stefanie,

 

I've checked this with our development. It is possible to get to the internal leaflet “map” object to work with, but it needs to be understood that it is an internal object and manipulating it directly is not recommended.

 

// private API

mainContext.switchingMapViewerAdapter.getMapAdapter().then(function(mapAdapter) {

    // do something with mapAdapter.__map

});

 

What exactly are you trying to achieve - what is the source of GeoJSON?

There are some examples how to add layers of various types using public API. It might be better to use BI panel for this case.

Is this polygon supposed to be interactive?

 

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 8
Registered: ‎10-03-2017

Re: Display of GeoJson polygon in map does not work

Hello Jan,

 

I am calling a Webservice via XMLHttpRequest and the response is a GeoJSON which should be displayed in the map.

There is no need for the polygon to be interactive. 

 

Thanks,

Stefanie

 

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: Display of GeoJson polygon in map does not work

Hi Stefanie,

 

Then I think it's still better to use BI panel instead of plain Map panel. There's a direct support for displaying dynamic geojson data. You just need to create a stage definition, having only the "choropleth" part makes things even easier. To simplify getting the stage model, you can create the stage by the wizard in Studio, using a sample geojson data. Then you can utilize gsp.bi.stage function package to retrieve information, and also to later manipulate the stage.

 

Some overview how to create custom stage model from the code is available here:

http://community.hexagongeospatial.com/t5/Shared-Samples/BI-Application-created-just-with-the-JS-CSS...

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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