GeoServer Layer Property Query and query results converted to the format that ArcGIS JS API can use

Source: Internet
Author: User

A project uses the ArcGIS JS API to develop a GIS presentation layer, but the GIS service uses geoserver, then load geoserver data and query data is completely different from before, the following introduction I use ArcGIS JS api+ A scenario that resolves GeoServer layer property queries during the GeoServer development process.

Take the example of a layer city published in GeoServer. I am now querying the id=53090000000000 objects in the city layer and using the ArcGIS JS API to display the results of the query.

First find the actual address of the query:

http://localhost:9999/geoserver/ replaced by self-workspace name /ows?service=wfs&version=1.0.0&request=getfeature &typename= replaced by his own workspace name :City &maxfeatures=-&outputformat=application/json &cql_filter=id=53090000000000

Do not take care of this address where to come, corresponding to the above need to change the place to try first. If not, you can modify some of the parameters by referring to the following procedure:

The first step:

Step Two:

Take a look at your own crawl, and finally change the output type in the fetch address to JSON. Refer to the example address given above.

After preparing for the above, it is the request. Build the URL address, using the Ajax POST request, if there are cross-domain problems can be jsonp or the background write a httppost program to convert.

We are concerned with the results of the request, such as:

The resulting results include field properties and graphical coordinates, where you can use Json2.js to complete the conversion of objects to JSON. Here the important introduction of the shape of the redrawing, we are concerned about the features under the coordinates.

Refer to the methods for creating polygons in the ArcGIS JS API, such as:

So I wrote:

var json = {    "rings": Points,    "spatialreference": {"Wkid": 4326}};var polygon = new Esri.geometry.Polygon (JSON);

The result is actually wrong, the middle experienced a lot of attempts, and later found the exact wording is this:

var feature = Features[i];var points = [];for (var n = 0; n < feature.geometry.coordinates.length; n++) {    Points.pu SH (feature.geometry.coordinates[n][0]);} var json = {    "rings": Points,    "spatialreference": {"Wkid": 4326}};var polygon = new Esri.geometry.Polygon (JSON);

Can only say GeoServer storage graphics coordinate mode and arcserver is not the same bar, here is a pit, hoping for the same fall into the pit of people a little help.

GeoServer Layer Property Query and query results converted to the format that ArcGIS JS API can use

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.