Draw lines over displayed shapefile

3579
4
Jump to solution
06-09-2015 04:08 PM
BryceBurr
New Contributor

Hi there

I have a basic Android app displaying a shape file of Australia.(shape file is hosted on the device)

I'd like to be able to draw a bunch of lines over the shape file.

ive tried the likes of

SimpleLineSymbol lineSymbol = new SimpleLineSymbol(Color.GREEN, 3, SimpleLineSymbol.STYLE.DASH);

     Polyline lineGeometry = new Polyline();

     lineGeometry.startPath(-24.862740, 151.990229);

     lineGeometry.lineTo(-28.088650, 152.643034);

     lineGeometry.lineTo(-24.520863, 150.836665);

  

   

     final Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);

     graphicsLayer.addGraphic(lineGraphic);

  mMapView.addLayer(graphicsLayer);

but nothing shows up over the shape file.....

Can someone point me in the correct direction as to what exactly i need to do?

cheers

Buzz

0 Kudos
1 Solution

Accepted Solutions
TeroRönkkö
Occasional Contributor

Hi,

yes, ESRI basemaps require internet connection so that is not option for you then.

Can you successfully draw points over the shapefile? And which spatial reference are you using on the layer? You can test that by getting getSpatialReference() from mapview – from that make sure your coordinates are of the correct type.

Are you running this on the emulator or on the device?

T

View solution in original post

4 Replies
TeroRönkkö
Occasional Contributor

In what function are you calling that?

Try this: declare your graphics layer on activitylevel, initialize it and add it to maplayer after your shapelayer.

Then after you make sure the map has been initialized, add that line to that graphicslayer. You can change the layer and it will show up on the map, no need to add the layer after changing.

And remembver that all coordinates must be in same coordinate system - if your shape uses any other than WGS(?) then those coordinates will go somewhere weird. Check if you can draw the line over base esri map without shapefile.

0 Kudos
BryceBurr
New Contributor

Hi

In what function are you calling that?

In the mainactivity's onCreate.

So as you recommended I had already added the shape file, and had been trying to add the lines afterwards.

But only the shape file shows up.

Check if you can draw the line over base esri map without shapefile.

Presumably the Esri base map is something the app must connect to over the internet - if this is the case  then the security "policy" here where i work means thats not an option. If this is not the case then can you explain to this novice what you mean

cheers

Buzzz

0 Kudos
TeroRönkkö
Occasional Contributor

Hi,

yes, ESRI basemaps require internet connection so that is not option for you then.

Can you successfully draw points over the shapefile? And which spatial reference are you using on the layer? You can test that by getting getSpatialReference() from mapview – from that make sure your coordinates are of the correct type.

Are you running this on the emulator or on the device?

T

BryceBurr
New Contributor

HI

so it was a muppet's error (i.e. mine)

to

  lineGeometry.startPath(151.990229,-24.862740);

*sigh* its always the "small" things.

cheers

Buzz

0 Kudos