Introduction to online web GIS data collection based on Arcgis for Js, arcgisgis

Source: Internet
Author: User
Tags polyline

Introduction to online web GIS data collection based on Arcgis for Js, arcgisgis

In the previous blog, "Conversion between WKT and geometry in Arcgis for js", the conversion between wkt and geometry is realized. The original blog address is http://blog.csdn.net/gisshixisheng/article/details/42657.pdf. In this section, we will briefly introduce online collection of web GIS data based on Arcgis for Js.


To achieve online data collection, the most important thing is data storage. The geometry object of the collected data is saved and can be converted to shp data later. In this article, my solution is to convert the previously drawn ry object to the wkt format and store it in the database. In the oracle database, use clob to store wkt.


Second, online data collection also needs to meet the following requirements:

1. Draw objects;

2. Edit an object;

3. Delete objects;

4. Display objects.


Next, let's take a look at the effect:


Main Window


Select Edit


Prompt after drawing is complete


Edit Point Set object


Click the map prompt to edit the information.


Deletion prompt


Deleted result

So far, online data collection is basically complete. Let's talk about the implementation steps.

1. drawing objects

The object is drawn through Edit, as shown below:

Var edit = new Edit (map); var select; edit. on ("deactivate", function (evt) {var geom = evt. graphic. geometry; var wkt = null; switch (geom. type) {case "polyline": {wkt = LineToWKT (geom); break;} case "polygon": {wkt = PolygonToWKT (geom); break;} default: {wkt = PointToWKT (geom); break ;}} if (confirm ('edit? ') {Console. log ("Edit:" + wkt) ;}}); map. on ("click", function (evt) {edit. deactivate ();});

EditItem = function (td) {var tr = td. parentElement; var objType = tr. id; var id = tr. cells [0]. innerHTML; var title = tr. cells [1]. innerHTML; $ ("# itemTitle" detail .html ("" detail .html (title); $ ("# itemType "). val ("point"); $ ("# itemObjtype "). val (objType) $ ("# editWindow "). show (); var draw = new Draw (map); draw. on ("draw-end", function (evt) {map. setMapCursor ("default"); var symbol = null, wkt; switch (evt. geometry. type) {Case "polyline": {symbol = new SimpleLineSymbol (SimpleLineSymbol. STYLE_SOLID, new Color ([255, 0, 0]), 3); wkt = LineToWKT (evt. geometry); break;} case "polygon": {symbol = new SimpleFillSymbol (SimpleFillSymbol. STYLE_SOLID, new SimpleLineSymbol (SimpleLineSymbol. STYLE_SOLID, new Color ([200,200,200, 0]), 2), new Color ([0.5,]); wkt = PolygonToWKT (evt. geometry); break;} default: {symbol = new Si MpleMarkerSymbol (SimpleMarkerSymbol. STYLE_SQUARE, 10, new SimpleLineSymbol (SimpleLineSymbol. STYLE_SOLID, new Color ([0,255, 0, 0]), 1), new Color ([0.25, 0,]); wkt = PointToWKT (evt. geometry); break;} var graphic = new Graphic (evt. geometry, symbol, {id: $ ("# itemObjtype "). val (), name: $ ("# itemTitle" ).html ()}); editLayer. add (graphic); draw. deactivate (); if (confirm ('Do you want to draw? ') {Console. log ("New:" + wkt) ;}}); on (dom. byId ("editBtn"), "click", function () {var objType = $ ("# itemType "). val (); switch (objType) {case "polyline": {draw. activate (esri. toolbars. draw. POLYLINE); break;} case "polygon": {draw. activate (esri. toolbars. draw. POLYGON); break;} default: {draw. activate (esri. toolbars. draw. POINT); break;} map. setMapCursor ("corsshair"); $ ("# editWindow "). hide ();});}

2. Edit an object

Object editing is implemented through Edit, as follows:

Var edit = new Edit (map); var select; edit. on ("deactivate", function (evt) {var geom = evt. graphic. geometry; var wkt = null; switch (geom. type) {case "polyline": {wkt = LineToWKT (geom); break;} case "polygon": {wkt = PolygonToWKT (geom); break;} default: {wkt = PointToWKT (geom); break ;}} if (confirm ('edit? ') {Console. log ("Edit:" + wkt) ;}}); map. on ("click", function (evt) {edit. deactivate () ;}); editLayer. on ("click", function (evt) {event. stop (evt); activateToolbar (evt. graphic) ;}); function activateToolbar (graphic) {var tool = 15; var options ={ allowAddVertices: "true", allowDeleteVertices: "true", uniformScaling: "true "}; edit. activate (tool, graphic, options); select = graphic ;}

3. Delete objects

DelItem = function (td) {if (confirm ('Delete? ') {Var id = tr. cells [0]. innerHTML; var graphics = editLayer. graphics; for (var I = 0, dl = graphics. length; I <dl; I ++) {var graphic = graphics [I]; if (graphic. attributes. id = id) {editLayer. remove (graphic); break ;}}}}


The last step is to pass the drawn geometry to the background. There are two main points. One is that after the drawing is complete, the code shows the draw-end event of the draw, and the other is after the editing is complete, the code shows the deactivate event of edit.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.