B4A Library Esri ArcGIS Runtime SDK for Android

This is a library that Ive been working on and off for a while now. I was waiting for the 10.2 release of the SDK before I released anything.

This is a work in progress as the SDK is very large. Ive only added core functions to prove it works for now.

Because of the license restrictions on the SDK I cannot release a compiled wrapper library that contains any Esri binaries - this is especially important to me since I work for an Esri distributor.

Attached are step by step instructions to let you compile the library yourself using the SLC tool.

So what is Esri and what is ArcGIS?

Basically its enterprise mapping. See www.esri.com and www.arcgis.com for more details.

This SDK lets you connect and use ArcGIS web/mapping services on your own premises or from Esri's cloud offering called Arcgis Online.

This is not basic mapping like Google maps as the Esri SDK contains a full GIS engine. While it displays maps the engine allows much more functionality like coordinate projections, spatial analysis, editing and with the 10.2 release offline capabilities.

Source is on Github

The wrapper source code is hosted on a public Github repository so feel free to contribute.
 

Attachments

  • Building AGSforAndroidProxy Wrapper.pdf
    454.7 KB · Views: 458
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
So how do you use the library?

There are plenty of Java samples and documentation on the Esri developers website;

https://developers.arcgis.com/en/android/api-reference/

The main mapping component is called the MapView.

Below is a very simple example of creating a MapView object and adding a map service to the map. It also creates a menu item that will turn the GPS on and zoom/pan the map to the GPS location. The B4A project is attached.

screenshot_2013-11-05-09-24-58-png.20307


B4X:
Sub Process_Globals

End Sub

Sub Globals
    Dim MapView1 As MapView
    Dim Location1 As LocationService
End Sub

Sub Activity_Create(FirstTime As Boolean)
    MapView1.Initialize("MapView1")

    Activity.AddView(MapView1,0,0,100%x,100%y)

    Dim tl As ArcGISTiledMapServiceLayer
    tl.Initialize("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer")

    MapView1.addLayer1(tl)

    Activity.AddMenuItem("Activate GPS", "mnuGPS")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub mnuGPS_click
    Location1 = MapView1.LocationService
    Location1.start
    Location1.AutoPan = True
    Location1.AccuracyCircleOn = True
    Location1.AllowNetworkLocation = True
End Sub
 

Attachments

  • HelloWorldMap.zip
    6 KB · Views: 307
  • Screenshot_2013-11-05-09-24-58.png
    Screenshot_2013-11-05-09-24-58.png
    288.9 KB · Views: 809
Last edited:

tcr49

Member
Licensed User
Longtime User
When following the step by step instructions in ‘Building AGSforAndroidProxy Wrapper.pdf’, to compile the wrapper library for ‘Esri ArcGIS Runtime SDK for Android’, it seems that the build is a success. But when the built library ‘AGSforAndroidProxy’ is selected this form is shown:

upload_2013-11-19_1-50-3-png.20556


Any help would be greatly appreciated. Thanks.
 

Attachments

  • upload_2013-11-19_1-50-3.png
    upload_2013-11-19_1-50-3.png
    11.8 KB · Views: 633

tchart

Well-Known Member
Licensed User
Longtime User
Sorry tcr49, I forgot to do a commit of the code as Erel said I should change "isInitialized" to "IsInitialized" to fix this issue.

Can you get the source from GitHub again and recompile? Ive just tested it and its compiling for me.
 

tcr49

Member
Licensed User
Longtime User
After getting your updated source from GitHub and recompiled, AGSforAndroidProxy loads as expected. Your example also works like a charm when the line 'MapView1.addLayer(tl)' is changed to ''MapView1.addLayer(tl,0)'. (addLayer also need the index of the layer).

Thank you for your good work.
 

tchart

Well-Known Member
Licensed User
Longtime User
tcr49, ah yes, sorry I need to update the example. Originally I hand coded much of the wrapper but now I have a semi-automated way to generated the wrapper code. The new method to add a layer without the index is "addLayer1".

If you look at the API documentation there are two addLayer methods. Since B4A doesn't support overrides I have to rename the second, third etc methods

https://developers.arcgis.com/en/an...tml#addLayer(com.esri.android.map.Layer, int)
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
Attached is a sample project showing how to use the geometry engine to project between coordinate systems.
 

Attachments

  • Projection.zip
    6.3 KB · Views: 254

Aleksandr

Member
Licensed User
Longtime User
Hi,
I can not understand how use Polyline or Polygone.

B4X:
    Dim Layer As GraphicsLayer  
    Dim g As Graphic
    Dim l As Polyline
    Dim s As SimpleLineSymbol
  

    l.addSegment(???, True)
    s.Initialize2(Colors.RED, 10, ???)
  
    g.Initialize(l, s)
    Layer.addGraphic(g)

how to extend the functionality of the most?
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User
Aleksandr, looks like I have missed the segment class. I will work on this today and get you a sample.
 

Aleksandr

Member
Licensed User
Longtime User
Ty.
I learned how to wrapped function will now fill functionality as needed.
Sorry for my English.
 

tchart

Well-Known Member
Licensed User
Longtime User
Aleksandr, glad you fixed it. Please share any sample code you have. Also feel free to add to the Github project.

I have upgraded the Github project to 10.2.2, I am testing it now.
 

Aleksandr

Member
Licensed User
Longtime User
I'am upgraded to 10.2.2 too.
I'am added only in to PolygonWrapper
B4X:
    //Starts a new path at a point.
    public void startPath(Point point)
    {
        getObject().startPath(point);
        return;
    }
  
    //Starts a new path at given coordinates.
    public void startPath2(double x, double y)
    {
        getObject().startPath(x, y);
        return;
    }
  
    //Adds a Line Segment to the given end point.
    public void lineTo(Point endPoint)
    {
        getObject().lineTo(endPoint);
        return;
    }
  
    //Adds a line segment from the last point to the given end coordinates.
    public void lineTo2(double x, double y)
    {
        getObject().lineTo(x, y);
        return;
    }

and PolylineWrapper for testing it. Sample code work good, line smoth it cool.
B4X:
    Dim Layer As GraphicsLayer  
    Dim g As Graphic
    Dim l As Polyline
    Dim s As SimpleLineSymbol
  
    Dim SRTo As SpatialReference
    Dim e As Envelope

    e.Initialize3(280586.2987, 5431792.8644, 719413.7013, 6655205.4835)
    SRTo.Initialize(2957)
    Layer.Initialize3(SRTo,e)
  
    l.Initialize
    l.startPath2(280596.2987,5431892.8644)
    l.lineTo2(719313.7013,6655105.4835)
    s.Initialize(Colors.RED, 10)
  
    g.Initialize(l, s)

    Layer.addGraphic(g)

    MapView1.addLayer1(Layer)
  
    MapView1.AllowRotationByPinch = True
  
    MapView1.enableWrapAround(True)
 

tchart

Well-Known Member
Licensed User
Longtime User
tamayo461, I have added the feature layer options to the source code on Github. Below is an example that is working;

B4X:
Dim fo As ArcGISFeatureLayer_Options 
fo.Initialize()
fo.mode = fo.MODE_ONDEMAND
fo.maxAllowableOffset = 0 

feature_layer.Initialize("http://mobilesampleserver.arcgisonline.com/ArcGIS/rest/services/DemoData/incidents_service/FeatureServer/0",fo)

MapView1.addLayer1(feature_layer)
 

Gerardo52

Member
Licensed User
Yes, the RunTime SDK does support offline maps but I have not tried it and the wrapper needs to be updated to the latest version.

Hi,
during compilation I receive this error.
C an you help me please?

Message when I start compile.bat

Library Name = AGSforAndroidProxy
Library Source Directory = "D:\PROGETTI\B4A\AGSforAndroidProxy-master\AGSforAndroidProxy-master"
B4A Library Compiler = D:\PROGETTI\B4A\SimpleLibraryCompiler\SimpleLibraryCompiler\LibraryCompiler.exe


Simple Library Compiler
Starting step: Compiling Java code.
exists: True
exists2: True
D:\PROGETTI\B4A\AGSforAndroidProxy-master\AGSforAndroidProxy-master\src\com\tchart\ags\proxy\android\action\IdentifyResultSpinnerAdapterWrapper.java:8: error: package com.esri.android.action does not exist
import com.esri.android.action.IdentifyResultSpinnerAdapter;
^
1 error

javac 11.0.1

Error.

Done!
 

Gerardo52

Member
Licensed User
Hi Tchart.
I am using the version I found on your github, following the suggestion of your 2013 post with the pdf instructions.
But does not compile

Thank you
 
Top