Drawing a Geometry Polygon using a geojson file

Discussions about creating CAPI applications to run on Android devices
Post Reply
munirmdee1
Posts: 75
Joined: August 17th, 2015, 9:32 am
Location: Dar es Salaam, Tanzania

Drawing a Geometry Polygon using a geojson file

Post by munirmdee1 »

Hello CSPro Users,

I have and application in which I need it to open a map and draw a polygon depending on the offline file saved in the device. I have an file named ea.geojson, after opening a satellite map, the application should be a able to draw that EA boundary according to the ea.geojson file.

I have tried it bu it does not work, maybe if I put logic here and tell me guys what went wrong

mymap.setBaseMap(Satellite);
geometry boundary;
boundary.load("./Maps/ea.geojson");
numeric geometryId = mymap.addGeometry(boundary);
mymap.show();

Staellite map opens successful but it does not show the EA boundary, loaded from thr geojson file.

Any help please, what is wrong is my syntax?

Thanks in advanced
Munir Mdee
Software Programmer
National Bureau of Statistic (NBS)
Jakaya Kikwete Road,
P.O.Box 2683,
Dodoma,TANZANIA
Mob: +255 755 740090
Email: munir.mdee@nbs.go.tz
munirmdee@gmail.com
aaronw
Posts: 565
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Drawing a Geometry Polygon using a geojson file

Post by aaronw »

I used your logic and it worked. I would verify the path to the geojson file and make sure the load succeeds. Then I would verify there isn't an issue with the geojson file. My suggestion would be to generate a new one using the Geometry example for your current location. Then display a map for your current location and load the geojson using your provided logic.
munirmdee1
Posts: 75
Joined: August 17th, 2015, 9:32 am
Location: Dar es Salaam, Tanzania

Re: Drawing a Geometry Polygon using a geojson file

Post by munirmdee1 »

Hi Aaron, maybe there is a problem with the geojson file, although I created it with QGIS, I there a sample geojson file that I can use to test?
Munir Mdee
Software Programmer
National Bureau of Statistic (NBS)
Jakaya Kikwete Road,
P.O.Box 2683,
Dodoma,TANZANIA
Mob: +255 755 740090
Email: munir.mdee@nbs.go.tz
munirmdee@gmail.com
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Drawing a Geometry Polygon using a geojson file

Post by Gregory Martin »

Attached is a GeoJSON file showing the location of the Census Bureau.
Attachments
Census Bureau.geojson
(211 Bytes) Downloaded 19 times
Post Reply