0.2.10 • Published 2 years ago

interpro-arcgis-mapview v0.2.10

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

interpro-arcgis-mapview

This project is froked from https://github.com/davidgalindo/react-native-arcgis-mapview.

Install the package and link it

$ yarn add interpro-arcgis-mapview
$ cd ios
$ pod install

Usage

import ArcGISMapView, { setLicenseKey } from 'interpro-arcgis-mapview';

const key = 'AAPK...IestQ';
setLicenseKey(key);
let agsView = useRef(null);

return (
  <ArcGISMapView
    style={styles.map}
    ref={element => agsView = element}
  />
);

const styles = StyleSheet.create({
  map: {
    flex: 4,
  },
});

Props

Prop NameTypeDescriptionSample Value
initialMapCenterObject ArraySpecifies the initial center of the map.[{latitude: 36.244797, longitude: -94.148060}]
recenterIfGraphicTappedBooleanIf true, the map will recenter if a graphic is tapped on.true / false
basemapUrlStringA URL that links to an ArcGIS Online map with your stylehttps://www.arcgis.com/home/item.html?id=5be0bc3ee36c4e058f7b3cebc21c74e6
spatialReferenceObjectSpecifies the spatial reference of the map.{ wkid: 4326 }

Callbacks

Callback NameDescriptionParameters
onSingleTapA callback that runs whenever the map is tapped once. A graphics ID is returned if a graphic was tapped on. A Geodatabase object props is returned if a feature object was tapped on.{ points: { mapPoint: {latitude: Number, longitude: Number}, screenPoint: {x: Number, y: Number}, }, graphicReferenceId: String?, geoElementAttributes: Object? }
onLongPressA callback that runs whenever the map is long press on.{ points: { mapPoint: {latitude: Number, longitude: Number}, screenPoint: {x: Number, y: Number}, }, graphicReferenceId: String?, geoElementAttributes: Object? }
onMapMovedCalled when map was moved.{ referenceId: String }
onMapDidLoadExecuted when the map finishes loading or runs into an error.{ success: Boolean, errorMessage: String? }
onOverlayWasAddedCalled when overlay is added.{ referenceId: String }
onOverlayWasModifiedCalled when an overlay was modified.{ referenceId: String, action: String, success: Boolean, errorMessage: String? }
onOverlayWasRemovedCalled when overlay is removed.{ referenceId: String }
onGeodatabaseWasAddedCalled when a Geodatabase feature layer is added.{ referenceId: String, featureLayers: [String], annotationLayers: [String] }
onGeodatabaseWasModifiedCalled when a Geodatabase feature layer was modified.{ referenceId: String, action: String, success: Boolean, errorMessage: String?, featureLayers: [String], annotationLayers: [String] }
onGeodatabaseWasRemovedCalled when Geodatabase feature layer is removed.{ referenceId: String }
onMapExportProgressCalled when map file export.{ fractionCompleted: Number, completedUnitCount: Number, debugDescription: String, isCancelled: Boolean, isFinished: Boolean, isPaused: Boolean, totalUnitCount: Number, description: String, estimatedTimeRemaining: String, fileCompletedCount: Number, fileTotalCount: Number, localizedDescription: String }

Methods

Callback NameDescriptionParameters
showCalloutCreates a callout popup with a title and description at the given point.{ point: {latitude, longitude} , title: String?, text String?, shouldRecenter: Boolean? }
recenterMapRecenters the map around the given point(s).[ {latitude: Number, longitude: Number, scale: Number?} ]
scaleMapSet scale of the map.Number
zoomMapSet zoom level of the map.Number
addGraphicsOverlayAdds a graphics overlay with the given points. See below for more information.{  pointGraphics: [graphicId: String, graphic: Image]?, referenceId: String, points: [Point] }
addPointsToOverlayAdds points to the overlay with the given overlayReferenceId.{ overlayReferenceId: String, points: [Point] }
removePointsFromOverlayRemoves points from the overlay with the given overlayReferenceID. The reference ID array are the IDs of the points you wish to remove.{ overlayReferenceId: String, referenceIds: [String] }
updatePointsOnOverlayUpdates points on a given overlay. All properties within an individual Point object are optional, though latitude and longitude must both be provided if you are updating either one. Animated controls whether or not the app should animate the transition from one point/rotation to another. Make sure each update is spaced about 500ms apart.{ overlayReferenceId: String, updates: [Point], animated: Boolean }
removeGraphicsOverlayRemoves the graphics overlay with the given ID.{ overlayId: String }
addGeodatabaseAdds Geodatabase feature layers.{ referenceId: String, geodatabaseURL: String, featureLayers: [{ referenceId: String, tableName: String, definitionExpression: String?, }], annotationLayers: [{ referenceId: String, tableName: String, }] }
addLayersToGeodatabaseAdds feature layers and annotation layers to the Geodatabase with the given geodatabaseReferenceId.{ geodatabaseReferenceId: String, featureLayers: [{ referenceId: String, tableName: String, definitionExpression: String? }], annotationLayers: [{ referenceId: String, tableName: String }] }
removeLayersFromGeodatabaseRemoves feature layers from the Geodatabase with the given geodatabaseReferenceID.{ geodatabaseReferenceId: String, featureLayerReferenceIds: [String], annotationLayerReferenceIds: [String] }
removeGeodatabaseRemoves the Geodatabase with the given ID.{ geodatabaseReferenceId: String }
getVisibleAreaGets polygon representing the map's visible area.
addBaseLayerAdds a base layer on basemap. Base layers are displayed at the bottom in a mapview, and reference layers are displayed at the top, with the map's operational layers sandwiched between them. The layers are drawn in a bottom-up fashion with the 0th layer in the list drawn first, next layer drawn on top of the previous one, and so on.{ referenceId: String, url: String }
removeBaseLayerRemoves a base layer on basemap.String
exportVectorTilesExport vector tiles and optionally a portal item's vector tile style resources. Download vector tiles and their associated style resources (as a vector tile package, .vtpk file){ temporaryDirectory: String, minScale: Number, minScale: Number }
setLicenseKeySet the default API key to access API key enabled services and resources in ArcGIS Online.String

The Point Object

Above, the Point object was referenced as 'Point.' The Point object is structured as follows:

{
  latitude: Number,
  longitude: Number,
  rotation: Number? = 0,
  referenceId: String,
  graphicId: String?,
}

The Image Object

When defining graphics, use the following format:

import { Image } from 'react-native';

pointGraphics: [
  { graphicId: 'graphicId', graphic: Image.resolveAssetSource(require('path_to_your_local_image')) },
  // Repeat for as many graphics as you'd like
]