pub struct MapServiceClient<'a> { /* private fields */ }Expand description
Client for interacting with an ArcGIS Map Service.
Map Services provide dynamic map rendering, cached tiles, metadata, legend information, and feature identification capabilities.
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient, ExportTarget};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let map_service = MapServiceClient::new(
"https://services.arcgis.com/org/arcgis/rest/services/MapName/MapServer",
&client,
);
// Export a map image
let result = map_service
.export()
.bbox("-180,-90,180,90")
.size(800, 600)
.execute(ExportTarget::to_path("map.png"))
.await?;Implementations§
Source§impl<'a> MapServiceClient<'a>
impl<'a> MapServiceClient<'a>
Sourcepub fn new(base_url: impl Into<String>, client: &'a ArcGISClient) -> Self
pub fn new(base_url: impl Into<String>, client: &'a ArcGISClient) -> Self
Creates a new Map Service client.
§Arguments
base_url- The base URL of the map service (e.g.,https://services.arcgis.com/.../MapServer)client- Reference to an authenticated ArcGIS client
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let map_service = MapServiceClient::new(
"https://services.arcgis.com/org/arcgis/rest/services/MapName/MapServer",
&client,
);Sourcepub fn export(&'a self) -> ExportMapBuilder<'a>
pub fn export(&'a self) -> ExportMapBuilder<'a>
Creates a fluent builder for exporting maps.
This is the recommended way to export maps. It provides a more
ergonomic API than manually constructing ExportMapParams.
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient, ExportTarget, ImageFormat};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new(
"https://services.arcgis.com/org/arcgis/rest/services/World/MapServer",
&client,
);
// Use the fluent export builder
let result = service
.export()
.bbox("-118.0,34.0,-117.0,35.0")
.size(800, 600)
.format(ImageFormat::Png32)
.transparent(true)
.execute(ExportTarget::to_bytes())
.await?;
if let Some(bytes) = result.bytes() {
println!("Exported {} bytes", bytes.len());
}Sourcepub async fn export_map(
&self,
params: ExportMapParams,
target: ExportTarget,
) -> Result<ExportResult>
pub async fn export_map( &self, params: ExportMapParams, target: ExportTarget, ) -> Result<ExportResult>
Exports a map with pre-built parameters.
For most use cases, prefer using the fluent export() builder.
This method is useful when you need to construct parameters programmatically
or reuse the same parameters multiple times.
§Arguments
params- Export parameters (bbox is required)target- Where to write the exported image (Path, Bytes, or Writer)
§Example
use arcgis::{
ApiKeyAuth, ArcGISClient, MapServiceClient, ExportMapParams,
ExportMapParamsBuilder, ExportTarget, ImageFormat,
};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let params = ExportMapParamsBuilder::default()
.bbox("-118.0,34.0,-117.0,35.0".to_string())
.size("800,600".to_string())
.format(ImageFormat::Png32)
.build()
.expect("Valid params");
let result = service
.export_map(params, ExportTarget::to_path("map.png"))
.await?;Sourcepub async fn export_tile(
&self,
coord: TileCoordinate,
target: ExportTarget,
) -> Result<ExportResult>
pub async fn export_tile( &self, coord: TileCoordinate, target: ExportTarget, ) -> Result<ExportResult>
Exports a tile from a cached map service.
Retrieves a specific tile from a tiled/cached map service. Not all map services support tiles - check service metadata first.
§Arguments
coord- Tile coordinate (level, row, column)target- Where to write the tile image (Path, Bytes, or Writer)
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient, TileCoordinate, ExportTarget};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
// Get tile at level 5, row 10, column 15
let coord = TileCoordinate::new(5, 10, 15);
let result = service
.export_tile(coord, ExportTarget::to_bytes())
.await?;Sourcepub async fn get_legend(&self) -> Result<LegendResponse>
pub async fn get_legend(&self) -> Result<LegendResponse>
Retrieves the legend for all layers in the map service.
The legend provides information about the symbols and labels used to represent features in each layer.
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let legend = service.get_legend().await?;
for layer in legend.layers() {
println!("Layer {}: {}", layer.layer_id(), layer.layer_name());
for symbol in layer.legend() {
println!(" - {}", symbol.label());
}
}Sourcepub async fn get_metadata(&self) -> Result<MapServiceMetadata>
pub async fn get_metadata(&self) -> Result<MapServiceMetadata>
Retrieves metadata about the map service.
Provides comprehensive information about the service including layers, spatial reference, extent, tile info (if cached), and capabilities.
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, MapServiceClient};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let metadata = service.get_metadata().await?;
println!("Layers: {}", metadata.layers().len());
if let Some(desc) = metadata.description() {
println!("Description: {}", desc);
}Sourcepub async fn identify(&self, params: IdentifyParams) -> Result<IdentifyResponse>
pub async fn identify(&self, params: IdentifyParams) -> Result<IdentifyResponse>
Identifies features at a specific location on the map.
Returns information about features from visible layers at the specified geometry (typically a point, but can be other geometries).
§Arguments
params- Identify parameters (geometry and image extent are required)
§Example
use arcgis::{
ApiKeyAuth, ArcGISClient, MapServiceClient, IdentifyParams,
IdentifyParamsBuilder, LayerSelection, GeometryType,
};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let params = IdentifyParamsBuilder::default()
.geometry("{\"x\":-118.0,\"y\":34.0}".to_string())
.geometry_type(GeometryType::Point)
.map_extent("-120,32,-116,36".to_string())
.image_display("800,600,96".to_string())
.layers(LayerSelection::Visible)
.build()
.expect("Valid params");
let response = service.identify(params).await?;
for result in response.results() {
println!("Found feature in layer {}", result.layer_id());
}Sourcepub async fn find(&self, params: FindParams) -> Result<FindResponse>
pub async fn find(&self, params: FindParams) -> Result<FindResponse>
Searches for features containing the specified text in a map service.
The find operation searches for text in one or more fields across multiple layers. It returns features that contain the search text along with their attributes and geometries.
§Arguments
params- Find parameters including search text, layers, and fields to search
§Example
use arcgis::{ArcGISClient, ApiKeyAuth, MapServiceClient, FindParams};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let params = FindParams::builder()
.search_text("Main Street")
.layers(vec![0, 1])
.search_fields(vec!["NAME".to_string(), "STREET".to_string()])
.build()
.expect("Valid params");
let result = service.find(params).await?;Sourcepub async fn generate_kml(&self, params: GenerateKmlParams) -> Result<String>
pub async fn generate_kml(&self, params: GenerateKmlParams) -> Result<String>
Generates KML (Keyhole Markup Language) output for the map service.
This operation returns a KML representation of the map that can be used in Google Earth and other KML viewers.
§Arguments
params- Parameters for KML generation including layers and image options
§Example
use arcgis::{ArcGISClient, ApiKeyAuth, MapServiceClient, GenerateKmlParams};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let params = GenerateKmlParams::builder()
.doc_name("MyMap")
.layers(vec![0, 1])
.build()
.expect("Valid params");
let kml = service.generate_kml(params).await?;Sourcepub async fn generate_renderer(
&self,
layer_id: i32,
params: GenerateRendererParams,
) -> Result<RendererResponse>
pub async fn generate_renderer( &self, layer_id: i32, params: GenerateRendererParams, ) -> Result<RendererResponse>
Generates a classification renderer for a layer.
This operation generates renderer definitions (symbols, colors, class breaks) based on the data in a layer field. Useful for creating dynamic visualizations like choropleth maps, graduated symbols, etc.
§Arguments
layer_id- The layer to generate renderer forparams- Parameters for renderer generation including classification method
§Example
use arcgis::{ArcGISClient, ApiKeyAuth, MapServiceClient, GenerateRendererParams};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
let params = GenerateRendererParams::builder()
.classification_field("POPULATION")
.classification_method("natural-breaks")
.break_count(5)
.build()
.expect("Valid params");
let renderer = service.generate_renderer(0, params).await?;Sourcepub async fn query_domains(
&self,
layers: Vec<LayerId>,
) -> Result<QueryDomainsResponse>
pub async fn query_domains( &self, layers: Vec<LayerId>, ) -> Result<QueryDomainsResponse>
Queries field domains and subtype information for map service layers.
This operation retrieves domain definitions (coded values, ranges) and subtype information for one or more layers in the map service. Useful for understanding valid values and field constraints.
§Arguments
layers- Vector of layer IDs to query domains for (empty for all layers)
§Example
use arcgis::{ArcGISClient, ApiKeyAuth, MapServiceClient, LayerId};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let service = MapServiceClient::new("https://example.com/MapServer", &client);
// Query domains for specific layers
let domains = service
.query_domains(vec![LayerId::new(0), LayerId::new(1)])
.await?;
// Query domains for all layers
let all_domains = service.query_domains(vec![]).await?;Auto Trait Implementations§
impl<'a> Freeze for MapServiceClient<'a>
impl<'a> !RefUnwindSafe for MapServiceClient<'a>
impl<'a> Send for MapServiceClient<'a>
impl<'a> Sync for MapServiceClient<'a>
impl<'a> Unpin for MapServiceClient<'a>
impl<'a> !UnwindSafe for MapServiceClient<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more