8
Views
4
Comments
Solved
[OutSystems Maps] Outsystems Maps KML or Geojson file Overlay issues
outsystems-maps
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hi All,

I want to implement a map with polygon reading form a GeoJson or KML files. 

I have followed the documentation in OutsystemsUI but not able to view the polygons in the file. 
Can anyone help me with what i am doing wrong?

Steps I followed:

1 - Google maps api with Key
2- Map component in the screen 
3- File Layer on the screen 
4- Geojson or KML file in Resources with Deploy to target location  
5- Create an expose api with file content in resources 
6- copy the Url of the api in the documentation
7- paste the url in File layers layer url property

Thanks

2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hi @Abhinava Reddy Muddamreddy 

This is what I get when opening the oml you attached:

Either way, I just confirmed that the File Layer add-on does not support GeoJSON files, and the documentation is incorrect. 
The add-on supports only KML and GeoRSS data formats. The documentation will be fixed in the next release to avoid further confusion.

To use the GeoJSON format, the customer must add a client action to the Map_Initialized event and create a JS Node with the code below (replacing the URL).

const map = OutSystems.Maps.MapAPI.MapManager.GetMapById($parameters.MapId).provider; 
map.data.loadGeoJson("https://storage.googleapis.com/mapsdevsite/json/google.json");

You can also use these documents as references:


Cheers,
GM

2022-11-12 11-28-30
Gonçalo Martins
Staff

Hello @Abhinava Reddy Muddamreddy 

Could you please share with the community what you have tried so far (by sharing a sample oml) and where you are having your struggles, so any help the community can provide can be more targeted and avoid spending time that's not needed for lack of information being shared?

Cheers,
GM

UserImage.jpg
Abhinava Reddy Muddamreddy

Hi GM, 

I have followed the Outsystems UI Maps  steps on how to use File layer addon.
 
I have also attached an oml as well. 

If we have any other way to integrate shapefiles in maps as well and any direction is appreciated.

Thanks
Abhinav

GeoJson.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hi @Abhinava Reddy Muddamreddy 

This is what I get when opening the oml you attached:

Either way, I just confirmed that the File Layer add-on does not support GeoJSON files, and the documentation is incorrect. 
The add-on supports only KML and GeoRSS data formats. The documentation will be fixed in the next release to avoid further confusion.

To use the GeoJSON format, the customer must add a client action to the Map_Initialized event and create a JS Node with the code below (replacing the URL).

const map = OutSystems.Maps.MapAPI.MapManager.GetMapById($parameters.MapId).provider; 
map.data.loadGeoJson("https://storage.googleapis.com/mapsdevsite/json/google.json");

You can also use these documents as references:


Cheers,
GM

2024-03-19 12-46-02
Bruno Gomes

Hello,
When I tried to use the code, map was undefined. Because there is no Outsystems.Maps.

So to load the geoJson the script was:

const map = MapAPI.MapManager.GetMapById($parameters.MapId).provider;

Thanks.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.