Hello everyone.
I'm developing an app that receives bluetooth data from a GPS to draw a map. However I need to make this data collection work offline. Is there any way to work with localization, drawing a map without displaying a background map (basemap)?
See an example in the attached image.
Solved! Go to Solution.
Ah I see what you are experiencing. I think you were trying to set a map that is NOT_LOADED to the MapView. (i.e map failing to load due to network unavailability) which is in turn not letting GraphicsOverlay to render.
You can try this,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
// create a map with just the Spatial Reference, so that only background grid is present
ArcGISMap map = new ArcGISMap(SpatialReference.create(3857));
// add graphics overlay to MapView.
GraphicsOverlay graphicsOverlay = addGraphicsOverlay(mMapView);
//add some buoy positions to the graphics overlay
addBuoyPoints(graphicsOverlay);
//add boat trip polyline to graphics overlay
addBoatTrip(graphicsOverlay);
//add nesting ground polygon to graphics overlay
addNestingGround(graphicsOverlay);
//add text symbols and points to graphics overlay
addText(graphicsOverlay);
// Now set empty map to mapview, that allows graphics overlay to render
mMapView.setMap(map);
// Then set the basemap to the map
map.setBasemap(Basemap.createDarkGrayCanvasVector());
}
Thanks
Rama
Hi,
You can draw a map without a Basemap defined. You can still have the other operational layers and GraphicsOverlays rendered on the Mapview.
Thanks
Rama
Hi Rama, thanks for the quick response.
But how can I do this? If I don't define a basemap, only a blank screen will be presented.
Hi,
Not defining a basemap will show the blankscreen with the background grid if there are no other operational layers defined in the map. It was not clear to me if that is what you want to achieve or not. Can you be more specific on the requirement for your app.
If you are specifically looking to work with an offline map that has a Basemap that works disconnected, then you can take one of the esri's Basemap offline and use it. The below samples do that by either downloading tile package from service or use an already downloaded tile package.
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/java/generate-offline-map
https://github.com/Esri/arcgis-runtime-samples-android/tree/main/java/generate-offline-map-with-loca...
Thanks
Rama
Hi Rana,
The purpose of the application that I am developing is to provide an offline working interface for users without internet connection. Right now I am using these tutorials that you indicated, but they are not ideal for my app.
According to the image (screenshot1) that I inserted in the attachment, I aim to present the current location of the user's app, drawing the map according to data received via bluetooth, but offline. I can perform this operation, but online only.
I am researching the best way to do this, however I am not able to present such data without a basemap.
Thank you for your attention.
I am assuming when you said `drawing the map according to data received via bluetooth`, you are actually drawing a layer of features/graphics on the map without a Basemap. Is that assumption correct? If so, Are you using GraphicsOverlays or FeatureLayer to represent the locations received via Bluetooth. Is there any sample code snippet you can share that hints at your current implementation which might explain/provide information on why it doesn't work while offline.
Thanks
Rama
Hi Rama,
"Is that assumption correct?" Yes, correct.
"Are you using GraphicsOverlays or FeatureLayer to represent the locations received via Bluetooth." Yes
The data received via bluetooth is not related to location (I don't get coordinates via bluetooth). The coordinates location is according to the current position of the device (mobile, tablet).
In the future the bluetooth device will send the coordinates of the current location.
The data I receive via bluetooth defines some parameters of what will be drawn on the map, such as the width and color of the path. See attached image for example.
I need internet to present a basemap, but i need internet to only present data received via bluetooth?
If you are using GraphicsOverlay to represent the bluetooth data, then it should not require internet. It will require internet incase if you are using FeatureLayer(ServiceFeatureTable)
Do you see any load errors on the layer's when there is no internet ?
Rama
Hi Rama.
I am using GraphicsOverlay to draw the data coming from bluetooth, however I cannot present this data offline. When there is no internet connection, the map does not appear, and as a result, the data that is in the GraphicsOverlay does not appear either.
Do you see any load errors on the layer's when there is no internet ?
The screen simply goes blank.
I don't know if I can explain it exactly.
Ah I see what you are experiencing. I think you were trying to set a map that is NOT_LOADED to the MapView. (i.e map failing to load due to network unavailability) which is in turn not letting GraphicsOverlay to render.
You can try this,
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
// create a map with just the Spatial Reference, so that only background grid is present
ArcGISMap map = new ArcGISMap(SpatialReference.create(3857));
// add graphics overlay to MapView.
GraphicsOverlay graphicsOverlay = addGraphicsOverlay(mMapView);
//add some buoy positions to the graphics overlay
addBuoyPoints(graphicsOverlay);
//add boat trip polyline to graphics overlay
addBoatTrip(graphicsOverlay);
//add nesting ground polygon to graphics overlay
addNestingGround(graphicsOverlay);
//add text symbols and points to graphics overlay
addText(graphicsOverlay);
// Now set empty map to mapview, that allows graphics overlay to render
mMapView.setMap(map);
// Then set the basemap to the map
map.setBasemap(Basemap.createDarkGrayCanvasVector());
}
Thanks
Rama