rn_supermap
Version:
rn_supermap 一款基于React-Native框架的移动应用开发工具。基于该开发工具,用户可以使用JavaScript开发语言,开发出在Android和IOS操作系统下运行的原生移动GIS应用,入门门槛低,一次开发,处处运行。
210 lines (185 loc) • 4.48 kB
JavaScript
/*********************************************************************************
Copyright © SuperMap. All rights reserved.
Author: Wang zihao
E-mail: pridehao@gmail.com
**********************************************************************************/
import { NativeModules } from 'react-native';
let R = NativeModules.JSRecordset;
import Geometry from './Geometry.js';
import Dataset from './Dataset';
/**
* @class Recordset
* @deprecated
*/
export default class Recordset {
async getRecordCount() {
try {
var { recordCount } = await R.getRecordCount(this._SMRecordsetId);
return recordCount;
} catch (e) {
console.error(e);
}
}
async dispose() {
try {
await R.dispose(this._SMRecordsetId);
} catch (e) {
console.error(e);
}
}
async getGeometry() {
try {
var { geometryId } = await R.getGeometry(this._SMRecordsetId);
var geometry = new Geometry();
geometry._SMGeometryId = geometryId;
return geometry;
} catch (e) {
console.error(e);
}
}
async isEOF() {
try {
var isEOF = await R.isEOF(this._SMRecordsetId);
return isEOF;
} catch (e) {
console.error(e);
}
}
async getDataset() {
try {
var { datasetId } = await R.getDataset(this._SMRecordsetId);
var dataset = new Dataset();
dataset._SMDatasetId = datasetId;
return dataset;
} catch (e) {
console.error(e);
}
}
async addNew(geometry) {
try {
await R.addNew(this._SMRecordsetId, geometry._SMGeometryId);
} catch (e) {
console.error(e);
}
}
async moveFirst() {
try {
let result = await R.moveFirst(this._SMRecordsetId);
return result;
} catch (e) {
console.error(e);
}
}
async moveNext() {
try {
await R.moveNext(this._SMRecordsetId);
} catch (e) {
console.error(e);
}
}
async moveLast() {
try {
await R.moveLast(this._SMRecordsetId);
} catch (e) {
console.error(e);
}
}
async movePrev() {
try {
await R.movePrev(this._SMRecordsetId);
} catch (e) {
console.error(e);
}
}
async moveTo(index) {
try {
await R.moveTo(this._SMRecordsetId, index);
} catch (e) {
console.error(e);
}
}
async edit() {
try {
let isEdit = await R.edit(this._SMRecordsetId);
return isEdit
} catch (e) {
console.error(e);
}
}
async update() {
try {
let isUpdate = await R.update(this._SMRecordsetId);
return isUpdate
} catch (e) {
console.error(e);
}
}
async getFieldCount() {
try {
let { count } = await R.getFieldCount(this._SMRecordsetId);
return count
} catch (e) {
console.error(e);
}
}
async getFieldInfo() {
try {
return (await R.getFieldInfo(this._SMRecordsetId))[0];
} catch (e) {
console.error(e);
}
}
async getFieldInfosArray(count = 0, size = 20) {
try {
let arr = await R.getFieldInfosArray(this._SMRecordsetId, count, size);
return arr
} catch (e) {
console.error(e);
}
}
async setFieldValueByName(info) {
try {
await R.setFieldValueByName(this._SMRecordsetId, info);
} catch (e) {
console.error(e);
}
}
async setFieldValueByIndex(info) {
try {
await R.setFieldValueByIndex(this._SMRecordsetId, info);
} catch (e) {
console.error(e);
}
}
async setFieldValuesByNames(infos = {}, position = -1) {
try {
let { result, editResult, updateResult } = await R.setFieldValueByName(this._SMRecordsetId, position, infos);
return { result, editResult, updateResult }
} catch (e) {
console.error(e);
}
}
async setFieldValuesByIndexes(infos = {}) {
try {
let { result, editResult, updateResult } = await R.setFieldValueByIndex(this._SMRecordsetId, infos);
return { result, editResult, updateResult }
} catch (e) {
console.error(e);
}
}
async addFieldInfo(info = {}) {
try {
let { index, editResult, updateResult } = await R.addFieldInfo(this._SMRecordsetId, info);
return { index, editResult, updateResult }
} catch (e) {
console.error(e);
}
}
async deleteById(id) {
try {
return await R.deleteById(this._SMRecordsetId, id);
} catch (e) {
console.error(e);
}
}
}