Hello all, I am new to ArcGIS-Android development environment.
I want to draw a point that shows my location, I used the following steps:
Defining a location variableز
2- Get the longitude and latitude from the location.
3- Creating a point from the longitude and latitude.
However, when I define the point that takes the longitude and latitude, I get an error (shown below in the screenshot). What might be the issue here?
Here is my code:
Location loc = null;
double lon,lat;
lon= loc.getLongitude();
lat= loc.getLatitude();
Point mlocation=new Point(lat,lon);
Try the following code to show the point.. also check what you imported.. the Point class should be com.esri.core.geometry.Point , and I think Android has a Point class as well.
// create a point marker symbol (red, size 10, of type circle)
SimpleMarkerSymbol simpleMarker = new SimpleMarkerSymbol(Color.RED, 10, SimpleMarkerSymbol.STYLE.CIRCLE); // create a point at x=-302557, y=7570663 (for a map using meters as units; this depends // on the spatial reference)
Point pointGeometry = new Point(-302557, 7570663); // create a graphic with the geometry and marker symbol
Graphic pointGraphic = new Graphic(pointGeometry, simpleMarker); // add the graphic to the graphics layer
graphicsLayer.addGraphic(pointGraphic);
Dear Mengyi,
I did exactly what you suggested (using this link) in a new project, but I get an error when creating the graphic point using :
Graphic pointGraphic = new Graphic(pointGeometry, simpleMarker);
I get this error: "The constructor Graphic(Point, SimpleMarkerSymbol) is undefined"
And it asks me to change the type of point to geometry or remove the arguments!!
Android SDK Tools Rev. 23.0.5
Android SDK Platforms-Tools Rev 21
Android SDK Build-Tools Rev 20
Android 5.0 (API 21)
SDK Plaform Rev. 1
Android 4.4W (API 20)
SDK Plaform Rev. 1
Android 4.4.2 (API 17)
SDK Platform Rev. 3
Google APIs Rev. 3
Android Support Library Rev. 21.0.1
Did you installed the eclipse plugin for ArcGIS Runtime SDK for Android? What is the version for that one?
Yes, plugin is installed; version 10.2.4.201410031154
Would you like to send your code to me? Maybe I can take a look at it.
Dear Mengyi,
Thank you for your prompt contribution.
I solved the point rendering problem by using this:
// create a point marker symbol (red, size 10, of type circle)
SimpleMarkerSymbol simpleMarker = new SimpleMarkerSymbol(Color.RED, 10, SimpleMarkerSymbol.STYLE.CIRCLE);
// create a point at x=-302557, y=7570663 (for a map using meters as units; this depends // on the spatial reference)
Geometry pointGeometry = new com.esri.core.geometry.Point(-302557, 7570663);
// create a graphic with the geometry and marker symbol
Graphic pointGraphic = new Graphic(pointGeometry, simpleMarker);
// add the graphic to the graphics layer
graphicsLayer.addGraphic(pointGraphic);
It seems that I should use Geometry pointGeometry = new com.esri.core.geometry.Point(-302557, 7570663);instead of Point pointGeometry = new Point(-302557, 7570663);
I see. However, com.esri.core.geometry.Point is the subclass of Geometry. So I think
Graphic pointGraphic = new Graphic(pointGeometry, simpleMarker);
should work for com.esri.core.geometry.Point
The reason why it gives the error maybe Point you are using is the Point class in Android rather than com.esri.core.geometry.Point. You can also try import com.esri.core.geometry and use Point directly.
Anyway, I'm glad your issue is solved:)