本文整理汇总了Java中com.esri.arcgisruntime.symbology.PictureMarkerSymbol类的典型用法代码示例。如果您正苦于以下问题:Java PictureMarkerSymbol类的具体用法?Java PictureMarkerSymbol怎么用?Java PictureMarkerSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PictureMarkerSymbol类属于com.esri.arcgisruntime.symbology包,在下文中一共展示了PictureMarkerSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showClickedLocation
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Create and add a marker to the map representing
* the clicked location.
* @param point - A com.esri.arcgisruntime.geometry.Point item
*/
@Override public void showClickedLocation(final Point point) {
final Bitmap icon = BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.blue_pin);
final BitmapDrawable drawable = new BitmapDrawable(getResources(), icon);
final PictureMarkerSymbol markerSymbol = new PictureMarkerSymbol(drawable);
markerSymbol.setHeight(40);
markerSymbol.setWidth(40);
markerSymbol.setOffsetY(markerSymbol.getHeight()/2);
markerSymbol.loadAsync();
markerSymbol.addDoneLoadingListener(new Runnable() {
@Override public void run() {
final Graphic marker = new Graphic(point, markerSymbol);
mGraphicOverlay.getGraphics().clear();
mGraphicOverlay.getGraphics().add(marker);
}
});
}
示例2: createFacilitiesAndGraphics
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Creates facilities around the San Diego region.
* <p>
* Facilities are created using point geometry which is then used to make graphics for the graphics overlay.
*/
private void createFacilitiesAndGraphics() {
// List of facilities to be placed around San Diego area
facilities = Arrays.asList(
new Facility(new Point(-1.3042129900625112E7, 3860127.9479775648, spatialReference)),
new Facility(new Point(-1.3042193400557665E7, 3862448.873041752, spatialReference)),
new Facility(new Point(-1.3046882875518233E7, 3862704.9896770366, spatialReference)),
new Facility(new Point(-1.3040539754780494E7, 3862924.5938606677, spatialReference)),
new Facility(new Point(-1.3042571225655518E7, 3858981.773018156, spatialReference)),
new Facility(new Point(-1.3039784633928463E7, 3856692.5980474586, spatialReference)),
new Facility(new Point(-1.3049023883956768E7, 3861993.789732541, spatialReference)));
// image for displaying facility
String facilityUrl = "http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png";
PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(facilityUrl);
facilitySymbol.setHeight(30);
facilitySymbol.setWidth(30);
// for each facility, create a graphic and add to graphics overlay
facilities.stream().map(f -> new Graphic(f.getGeometry(), facilitySymbol))
.collect(Collectors.toCollection(() -> facilityGraphicsOverlay.getGraphics()));
}
示例3: placePictureMarkerSymbol
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Adds a Graphic to the Graphics Overlay using a Point and a Picture Marker
* Symbol.
*
* @param markerSymbol PictureMarkerSymbol to be used
* @param graphicPoint where the Graphic is going to be placed
*/
private void placePictureMarkerSymbol(PictureMarkerSymbol markerSymbol, Point graphicPoint) {
// set size of the image
markerSymbol.setHeight(40);
markerSymbol.setWidth(40);
// load symbol asynchronously
markerSymbol.loadAsync();
// add to the graphic overlay once done loading
markerSymbol.addDoneLoadingListener(() -> {
if (markerSymbol.getLoadStatus() == LoadStatus.LOADED) {
Graphic symbolGraphic = new Graphic(graphicPoint, markerSymbol);
graphicsOverlay.getGraphics().add(symbolGraphic);
} else {
Alert alert = new Alert(Alert.AlertType.ERROR, "Picture Marker Symbol Failed to Load!");
alert.show();
}
});
}
示例4: createPictureMarkerSymbolFromFile
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Create a picture marker symbol from an image on disk. Called from checkSaveResourceToExternalStorage() or
* onRequestPermissionsResult which validate required external storage and permissions
*/
private void createPictureMarkerSymbolFromFile() {
//[DocRef: Name=Picture Marker Symbol File-android, Category=Fundamentals, Topic=Symbols and Renderers]
//Create a picture marker symbol from a file on disk
BitmapDrawable pinBlankOrangeDrawable = (BitmapDrawable) Drawable.createFromPath(mPinBlankOrangeFilePath);
final PictureMarkerSymbol pinBlankOrangeSymbol = new PictureMarkerSymbol(pinBlankOrangeDrawable);
//Optionally set the size, if not set the image will be auto sized based on its size in pixels,
//its appearance would then differ across devices with different resolutions.
pinBlankOrangeSymbol.setHeight(20);
pinBlankOrangeSymbol.setWidth(20);
//Optionally set the offset, to align the base of the symbol aligns with the point geometry
pinBlankOrangeSymbol.setOffsetY(10); //The image used has not buffer and therefore the Y offset is height/2
pinBlankOrangeSymbol.loadAsync();
//[DocRef: END]
pinBlankOrangeSymbol.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
//add a new graphic with the same location as the initial viewpoint
Point pinBlankOrangePoint = new Point(-228835, 6550763, SpatialReferences.getWebMercator());
Graphic pinBlankOrangeGraphic = new Graphic(pinBlankOrangePoint, pinBlankOrangeSymbol);
mGraphicsOverlay.getGraphics().add(pinBlankOrangeGraphic);
}
});
}
示例5: showReverseGeocodeResult
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Displays any gecoded results by add a PictureMarkerSymbol to the map's
* graphics layer.
*
* @param results
* A list of GeocodeResult items
*/
private void showReverseGeocodeResult(List<GeocodeResult> results) {
if (results != null && results.size() > 0) {
// Show the first item returned
// Address string is saved for use in routing
mLocationLayerPointString = results.get(0).getLabel();
mFoundLocation = results.get(0).getDisplayLocation();
// Draw marker on map.
// create marker symbol to represent location
BitmapDrawable bitmapDrawable = (BitmapDrawable) ContextCompat
.getDrawable(getActivity().getApplicationContext(), R.drawable.pin_circle_red);
PictureMarkerSymbol destinationSymbol = new PictureMarkerSymbol(bitmapDrawable);
mLocationLayer.getGraphics().add(new Graphic(mFoundLocation, destinationSymbol));
// center the map to result location
mMapView.setViewpointCenterAsync(mFoundLocation);
// Show the result on the search result layout
showSearchResultLayout(mLocationLayerPointString);
}
}
示例6: clearCenteredPin
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Restore a pin to its default color
*/
private void clearCenteredPin(){
if (mCenteredGraphic != null){
mCenteredGraphic.setZIndex(0);
final BitmapDrawable oldPin = (BitmapDrawable) ContextCompat.getDrawable(getActivity(),getDrawableForPlace(mCenteredPlace)) ;
mCenteredGraphic.setSymbol(new PictureMarkerSymbol(oldPin));
}
}
示例7: createMarkerGraphic
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
private Graphic createMarkerGraphic(Point point, boolean endPoint) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) ContextCompat.getDrawable(
getActivity().getApplicationContext(),
endPoint ? R.drawable.pin_circle_blue : R.drawable.pin_circle_red);
PictureMarkerSymbol destinationSymbol = new PictureMarkerSymbol(bitmapDrawable);
// NOTE: marker's bounds not set till marker is used to create
// destinationSymbol
float offsetY = convertPixelsToDp(getActivity(),
bitmapDrawable.getBounds().bottom);
destinationSymbol.setOffsetY(offsetY);
return new Graphic(point, destinationSymbol);
}
示例8: addGraphicToMap
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
private void addGraphicToMap(BitmapDrawable bitdrawable, Geometry geometry){
final PictureMarkerSymbol pinSymbol = new PictureMarkerSymbol(bitdrawable);
final Graphic graphic = new Graphic(geometry, pinSymbol);
mGraphicOverlay.getGraphics().add(graphic);
}
示例9: centerOnPlace
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Center the selected place and change the pin
* color to blue.
* @param p - the selected place
*/
@Override public final void centerOnPlace(final Place p) {
if (p.getLocation() == null){
return;
}
// Dismiss the route header view
removeRouteHeaderView();
// Keep track of centered place since
// it will be needed to reset
// the graphic if another place
// is centered.
mCenteredPlace = p;
// Stop listening to navigation changes
// while place is centered in map.
removeNavigationChangedListener();
final ListenableFuture<Boolean> viewCentered = mMapView.setViewpointCenterAsync(p.getLocation());
viewCentered.addDoneListener(new Runnable() {
@Override public void run() {
// Once we've centered on a place, listen
// for changes in viewpoint.
if (mNavigationChangedListener == null){
setNavigationChangeListener();
}
}
});
// Change the pin icon
clearCenteredPin();
final List<Graphic> graphics = mGraphicOverlay.getGraphics();
for (final Graphic g : graphics){
if (g.getGeometry().equals(p.getLocation())){
mCenteredGraphic = g;
mCenteredGraphic.setZIndex(3);
final BitmapDrawable pin = (BitmapDrawable) ContextCompat.getDrawable(getActivity(),getPinForCenterPlace(p)) ;
final PictureMarkerSymbol pinSymbol = new PictureMarkerSymbol(pin);
g.setSymbol(pinSymbol);
break;
}
}
}
示例10: initialize
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
@FXML
public void initialize() {
ArcGISMap map = new ArcGISMap(Basemap.createStreets());
mapView.setMap(map);
// set mapview to San Diego
mapView.setViewpoint(new Viewpoint(32.73, -117.14, 60000));
// create service area task from url
final String SanDiegoRegion = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ServiceArea";
serviceAreaTask = new ServiceAreaTask(SanDiegoRegion);
serviceAreaTask.loadAsync();
// create default parameters from task
ListenableFuture<ServiceAreaParameters> parameters = serviceAreaTask.createDefaultParametersAsync();
parameters.addDoneListener(() -> {
try {
serviceAreaParameters = parameters.get();
serviceAreaParameters.setPolygonDetail(ServiceAreaPolygonDetail.HIGH);
serviceAreaParameters.setReturnPolygons(true);
// adding another service area of 2 minutes
// default parameters have a default service area of 5 minutes
serviceAreaParameters.getDefaultImpedanceCutoffs().addAll(Arrays.asList(2.0));
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace();
}
});
// for displaying graphics to mapview
serviceAreasOverlay = new GraphicsOverlay();
facilityOverlay = new GraphicsOverlay();
barrierOverlay = new GraphicsOverlay();
mapView.getGraphicsOverlays().addAll(Arrays.asList(serviceAreasOverlay, barrierOverlay, facilityOverlay));
barrierBuilder = new PolylineBuilder(spatialReference);
serviceAreaFacilities = new ArrayList<>();
SimpleLineSymbol outline = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF000000, 3.0f);
fillSymbols = new ArrayList<>();
fillSymbols.add(new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x66FF0000, outline));
fillSymbols.add(new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0x66FFA500, outline));
// icon used to display facilities to mapview
String facilityUrl = "http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png";
PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(facilityUrl);
facilitySymbol.setHeight(30);
facilitySymbol.setWidth(30);
// creates facilities and barriers at user's clicked location
mapView.setOnMouseClicked(e -> {
if (e.getButton() == MouseButton.PRIMARY && e.isStillSincePress()) {
// create a point from where the user clicked
Point2D point = new Point2D(e.getX(), e.getY());
Point mapPoint = mapView.screenToLocation(point);
if (btnAddFacility.isSelected()) {
// create facility from point and display to mapview
Point servicePoint = new Point(mapPoint.getX(), mapPoint.getY(), spatialReference);
serviceAreaFacilities.add(new ServiceAreaFacility(servicePoint));
facilityOverlay.getGraphics().add(new Graphic(servicePoint, facilitySymbol));
} else if (btnAddBarrier.isSelected()) {
// create barrier and display to mapview
barrierBuilder.addPoint(new Point(mapPoint.getX(), mapPoint.getY(), spatialReference));
barrierOverlay.getGraphics().add(barrierOverlay.getGraphics().size(), new Graphic(barrierBuilder.toGeometry(), outline));
}
}
});
}
示例11: start
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
try {
// create stack pane and application scene
StackPane stackPane = new StackPane();
Scene scene = new Scene(stackPane);
// set title, size, and add scene to stage
stage.setTitle("Picture Marker Symbol Sample");
stage.setWidth(800);
stage.setHeight(700);
stage.setScene(scene);
stage.show();
// create a ArcGISMap with the topograph basemap
final ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
// create view for this map
mapView = new MapView();
// create graphics overlay and add it to the mapview
graphicsOverlay = new GraphicsOverlay();
mapView.getGraphicsOverlays().add(graphicsOverlay);
// create points for displaying graphics
Point leftPoint = new Point(-228835, 6550763, SpatialReferences.getWebMercator()); // Disk
Point rightPoint = new Point(-223560, 6552021, SpatialReferences.getWebMercator()); // URL
Point middlePoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
// create orange picture marker symbol from disk
if (saveResourceToExternalStorage()) {
// create orange picture marker symbol
PictureMarkerSymbol orangeSymbol = new PictureMarkerSymbol(orangeSymbolPath.getAbsolutePath());
// place orange picture marker symbol on ArcGISMap
placePictureMarkerSymbol(orangeSymbol, leftPoint);
}
// create blue picture marker symbol from local
Image newImage = new Image("/symbols/blue_symbol.png");
PictureMarkerSymbol blueSymbol = new PictureMarkerSymbol(newImage);
// place blue picture marker symbol on ArcGISMap
placePictureMarkerSymbol(blueSymbol, middlePoint);
// create campsite picture marker symbol from URL
PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(CAMPSITE_SYMBOL);
// place campsite picture marker symbol on ArcGISMap
map.addDoneLoadingListener(() -> {
if (map.getLoadStatus() == LoadStatus.LOADED) {
Platform.runLater(() -> placePictureMarkerSymbol(campsiteSymbol, rightPoint));
} else {
Alert alert = new Alert(Alert.AlertType.ERROR, "Map Failed to Load!");
alert.show();
}
});
// set ArcGISMap to be displayed in mapview
mapView.setMap(map);
// set viewpoint on mapview with padding
Envelope envelope = new Envelope(leftPoint, rightPoint);
mapView.setViewpointGeometryAsync(envelope, 100.0);
// add the map view and control panel to stack pane
stackPane.getChildren().add(mapView);
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: setUpOfflineMapGeocoding
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
private void setUpOfflineMapGeocoding() {
// create a basemap from a local tile package
TileCache tileCache = new TileCache(extern + getResources().getString(R.string.sandiego_tpk));
tiledLayer = new ArcGISTiledLayer(tileCache);
Basemap basemap = new Basemap(tiledLayer);
// create ArcGISMap with imagery basemap
mMap = new ArcGISMap(basemap);
mMapView.setMap(mMap);
mMap.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
Point p = new Point(-117.162040, 32.718260, SpatialReference.create(4326));
Viewpoint vp = new Viewpoint(p, 10000);
mMapView.setViewpointAsync(vp, 3);
}
});
// add a graphics overlay
graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.setSelectionColor(Color.CYAN);
mMapView.getGraphicsOverlays().add(graphicsOverlay);
mGeocodeParameters = new GeocodeParameters();
mGeocodeParameters.getResultAttributeNames().add("*");
mGeocodeParameters.setMaxResults(1);
//[DocRef: Name=Picture Marker Symbol Drawable-android, Category=Fundamentals, Topic=Symbols and Renderers]
//Create a picture marker symbol from an app resource
BitmapDrawable startDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin);
mPinSourceSymbol = new PictureMarkerSymbol(startDrawable);
mPinSourceSymbol.setHeight(90);
mPinSourceSymbol.setWidth(20);
mPinSourceSymbol.loadAsync();
mPinSourceSymbol.setLeaderOffsetY(45);
mPinSourceSymbol.setOffsetY(-48);
mReverseGeocodeParameters = new ReverseGeocodeParameters();
mReverseGeocodeParameters.getResultAttributeNames().add("*");
mReverseGeocodeParameters.setOutputSpatialReference(mMap.getSpatialReference());
mReverseGeocodeParameters.setMaxResults(1);
mLocatorTask = new LocatorTask(extern + getResources().getString(R.string.sandiego_loc));
mCalloutContent = new TextView(getApplicationContext());
mCalloutContent.setTextColor(Color.BLACK);
mCalloutContent.setTextIsSelectable(true);
}
示例13: onCreate
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
@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 the imagery basemap
ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
// set the map to be displayed in the mapview
mMapView.setMap(map);
// create an initial viewpoint using an envelope (of two points, bottom left and top right)
Envelope envelope = new Envelope(new Point(-228835, 6550763, SpatialReferences.getWebMercator()),
new Point(-223560, 6552021, SpatialReferences.getWebMercator()));
//set viewpoint on mapview
mMapView.setViewpointGeometryAsync(envelope, 100.0);
// create a new graphics overlay and add it to the mapview
mGraphicsOverlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(mGraphicsOverlay);
//[DocRef: Name=Picture Marker Symbol URL, Category=Fundamentals, Topic=Symbols and Renderers]
//Create a picture marker symbol from a URL resource
//When using a URL, you need to call load to fetch the remote resource
final PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae");
//Optionally set the size, if not set the image will be auto sized based on its size in pixels,
//its appearance would then differ across devices with different resolutions.
campsiteSymbol.setHeight(18);
campsiteSymbol.setWidth(18);
campsiteSymbol.loadAsync();
//[DocRef: END]
campsiteSymbol.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
//Once the symbol has loaded, add a new graphic to the graphic overlay
Point campsitePoint = new Point(-223560, 6552021, SpatialReferences.getWebMercator());
Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol);
mGraphicsOverlay.getGraphics().add(campsiteGraphic);
}
});
//[DocRef: Name=Picture Marker Symbol Drawable-android, Category=Fundamentals, Topic=Symbols and Renderers]
//Create a picture marker symbol from an app resource
BitmapDrawable pinStarBlueDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_star_blue);
final PictureMarkerSymbol pinStarBlueSymbol = new PictureMarkerSymbol(pinStarBlueDrawable);
//Optionally set the size, if not set the image will be auto sized based on its size in pixels,
//its appearance would then differ across devices with different resolutions.
pinStarBlueSymbol.setHeight(40);
pinStarBlueSymbol.setWidth(40);
//Optionally set the offset, to align the base of the symbol aligns with the point geometry
pinStarBlueSymbol.setOffsetY(
11); //The image used for the symbol has a transparent buffer around it, so the offset is not simply height/2
pinStarBlueSymbol.loadAsync();
//[DocRef: END]
pinStarBlueSymbol.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
//add a new graphic with the same location as the initial viewpoint
Point pinStarBluePoint = new Point(-226773, 6550477, SpatialReferences.getWebMercator());
Graphic pinStarBlueGraphic = new Graphic(pinStarBluePoint, pinStarBlueSymbol);
mGraphicsOverlay.getGraphics().add(pinStarBlueGraphic);
}
});
//see createPictureMarkerSymbolFromFile() method for implementation
//first run checks for external storage and permissions,
checkSaveResourceToExternalStorage();
}
示例14: onCreate
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// inflate address search view
mAddressSearchView = (SearchView) findViewById(R.id.addressSearchView);
mAddressSearchView.setIconified(false);
mAddressSearchView.setFocusable(false);
mAddressSearchView.setQueryHint(getResources().getString(R.string.address_search_hint));
// define pin drawable
BitmapDrawable pinDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin);
try {
mPinSourceSymbol = PictureMarkerSymbol.createAsync(pinDrawable).get();
} catch (InterruptedException | ExecutionException e) {
Log.e(TAG, "Picture Marker Symbol error: " + e.getMessage());
Toast.makeText(getApplicationContext(), "Failed to load pin drawable.", Toast.LENGTH_LONG).show();
}
// set pin to half of native size
mPinSourceSymbol.setWidth(19f);
mPinSourceSymbol.setHeight(72f);
// create a LocatorTask from an online service
mLocatorTask = new LocatorTask("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");
// inflate MapView from layout
mMapView = (MapView) findViewById(R.id.mapView);
// create a map with the BasemapType topographic
final ArcGISMap map = new ArcGISMap(Basemap.createStreetsVector());
// set the map to be displayed in this view
mMapView.setMap(map);
// set the map viewpoint to start over North America
mMapView.setViewpoint(new Viewpoint(40, -100, 100000000));
// add listener to handle screen taps
mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) {
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
identifyGraphic(motionEvent);
return true;
}
});
// define the graphics overlay
mGraphicsOverlay = new GraphicsOverlay();
setupAddressSearchView();
}
示例15: setUpOfflineMapGeocoding
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; //导入依赖的package包/类
/**
* Sets up a LocatorTask from the loaded mobile map package, and graphics to show results from running the task.
* Shows a message to user if Locator task is not found.
*/
private void setUpOfflineMapGeocoding() {
if (mMobileMapPackage.getLocatorTask() == null) {
Snackbar.make(mMapView, "Current mobile map package has no LocatorTask", Snackbar.LENGTH_SHORT).show();
return;
}
// Get LocatorTask from loaded MobileMapPackage and listen for loading events
mLocatorTask = mMobileMapPackage.getLocatorTask();
mLocatorTask.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
if (mLocatorTask.getLoadStatus() != LoadStatus.LOADED) {
Snackbar.make(mMapView, String.format(getString(R.string.object_not_loaded), "LocatorTask"),
Snackbar.LENGTH_SHORT).show();
}
}
});
mLocatorTask.loadAsync();
// Add a graphics overlay that will be used for geocoding results
graphicsOverlay = new GraphicsOverlay();
graphicsOverlay.setSelectionColor(0xFF00FFFF);
mMapView.getGraphicsOverlays().add(graphicsOverlay);
// Define the parameters that will be used by the locator task
mGeocodeParameters = new GeocodeParameters();
mGeocodeParameters.getResultAttributeNames().add("*");
mGeocodeParameters.setMaxResults(10); //1);
mGeocodeParameters.setOutputSpatialReference(mMapView.getSpatialReference());
//Create picture marker symbols from app resources for geocode results
BitmapDrawable addressDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_blank_orange);
mFromAddressSymbol = new PictureMarkerSymbol(addressDrawable);
mFromAddressSymbol.setHeight(64);
mFromAddressSymbol.setWidth(64);
mFromAddressSymbol.loadAsync();
mFromAddressSymbol.setLeaderOffsetY(32);
mFromAddressSymbol.setOffsetY(32);
BitmapDrawable hydrantDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin_circle_blue_d);
mToAddressSymbol = new PictureMarkerSymbol(hydrantDrawable);
mToAddressSymbol.setHeight(64);
mToAddressSymbol.setWidth(64);
mToAddressSymbol.loadAsync();
mToAddressSymbol.setLeaderOffsetY(32);
mToAddressSymbol.setOffsetY(32);
}