MSDK Import Third-party Map
This article instructs users how to import third-party map to achieve centralized map management via DJI MapWidget.
How to Import 3rd-party Map
We take importing amap as an example to introduce how to import 3rd-party map. Click to view the complete code.
- Create File Folder
Refer to the following feature to create amap file folder and its subfolder. No restrictions on the location or name of the folder.

- Method Realization
.
└── amap
├── annotations
├── map
├── place
├── provider
└── utils
annotations annotation | Refer to the sample to implement DJICircle, DJIGroupCircle, DJIMarker, DJIPolygon, DJIPolyline |
---|---|
map map operations | Refer to the sample to implement DJIBaseMap: map operations such as long press event. TextureMapView: primarily control the lifecycle for map view. DJIProjection: responsible for the switching between the screen coordinates and geographic coordinates. DJIUiSettings: primarily responsible for some map's built-in widgets, such as scale. Gesture: whether is allowed to rotate or not. |
place map search | Refer to the sample to implement IInternalPlacesClient、PoiSearch.OnPoiSearchListener |
provider add maps | Refer to the sample to implement MapProvider |
Map Related Common Operations
- Marker Operations
DJIMap mMap;
DJIBitmapDescriptor icon = DJIBitmapDescriptorFactory.fromResource(R.drawable.gs_user_annotation_image);
DJIMarker locMarker;
// Add Marker
locMarker = mMap.addMarker(new DJIMarkerOptions()
.draggable(false)
.position(latLng)
.anchor(0.5f, 0.5f)
.icon(icon));
// Rotate Marker
locMarker.setRotation(rotation);
//Remove
locMarker.remove();
- Circle Operations
DJIMap mMap;
DJICircle circle;
// Add
DJICircle circle = mMap.addCircle(new DJICircleOptions()
.center(new DJILatLng(latLng))
.radius(radius)
.strokeWidth(5)
.strokeColor(unLimitStrokeColor)
.fillColor(unLimitFillColor));
// Remove
circle.remove();
- Polyline Operations
DJIMap mMap;
// Add Polyline
DJIPolylineOptions options = new DJIPolylineOptions()
.width(width)
.color(color)
.geodesic(true)
.add(homeMarker.getPosition(), flyMarker.getPosition())
.ZIndex(655510);
DJIPolyline line = mMap.addPolyline(options);
// Update Polyline
options.width(newWidth);
line.setOptions(options);
// Remove
line.remove();
- Polygon Operations
DJIMap mMap;
// Add
DJIPolygon plg = mMap.addPolygon(new DJIPolygonOptions().addAll(points)
.strokeColor(mColorTransparent)
.strokeWidth(4f)
.fillColor(fillColor));
// Remove
pig.remove();
- Rotate Map (which is rotating the Camera)
DJIMap mMap;
float newBearing;
// Obtain current Camera
DJICameraPosition p = mMap.getCameraPosition();
DJICameraPosition position = new DJICameraPosition.Builder()
.target(p.target)
.zoom(p.zoom)
.tilt(p.tilt)
.bearing(newBearing)
.build();
// Update Camera
mMap.animateCamera(DJICameraUpdateFactory.newCameraPosition(position));
// or
mMap.moveCamera(DJICameraUpdateFactory.newCameraPosition(position));
- Projection Operations
DJIMap mMap;
Point point; // Point coordinates on the screen
// Obtain map coordinates from screen point
DJIProjection projection = mMap.getProjection();
DJILatLng p = projection.fromScreenLocation(point);
// Obtain screen point from map coordinates
DJIProjection projection = mMap.getProjection();
Point p = projection.toScreenLocation(marker.getPosition());
- Usage for DJILatLngBounds
DJIMap mMap;
DJILatLngBounds.Builder builder = new DJILatLngBounds.Builder();
builder.include(locMarker.getPosition());
builder.include(flyMarker.getPosition());
builder.include(homeMarker.getPosition());
final DJILatLngBounds bounds = builder.build();
mMap.moveCamera(DJICameraUpdateFactory.newLatLngBounds(bounds, width, height, 10));