0.1.1 • Published 2 years ago

ll-arcgis-mapview v0.1.1

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

ll-arcgis-mapview

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

Install the package and link it

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

Usage

import ArcGISMapView, { setLicenseKey } from 'll-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, scale: 10000.0}]
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

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? }
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 }

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?} ]
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 }`

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
]