Giter Club home page Giter Club logo

Comments (7)

DavidSpriggs avatar DavidSpriggs commented on June 12, 2024

This is an excellent find and addition to the project. I would use the geometry service object rather than a straight ajax request. Also, simply use the maps spatial reference rather than setting it in the config.

The best way to contribute code is to use git/github. Clone the repo and submit pull requests. There are good tutorials on github about how to do this.

For now I can manually integrate this into the viewer.

from cmv-app.

kgerhartz avatar kgerhartz commented on June 12, 2024

Have been trying all morning to change this to use a geometryservice with no luck. The call to the project method acts like it is not being recognized. Can't even get it to throw an error. Do you see anything obvious?

    locationSuccess: function(event) {

        this.graphics.clear();
        //Create point to be projected from geolocate operation
        var point = new esri.geometry.mapPoint(event.coords.longitude, event.coords.latitude, new SpatialReference({
            wkid: 4326
        }));

        //Variables necessary for reprojection
        gsvc = esri.tasks.GeometryService("http://gis/arcgis/rest/services/Utilities/Geometry/GeometryServer");
        var params = new esri.tasks.ProjectParameters();
        params.geometries = [point];
        params.outSR = this.map.spatialReference.wkid;
        alert(params.outSR);  

        gsvc.project(params, 
          function (projectedPoints) {
            //  get the projected point
            pt = projectedPoints[0];
            //  add it to the map
            this.addGraphic(pt);
            //  zoom the map to the added point
            this.map.centerAndZoom(pt, 4);
          },function(){alert("error");}
        );

}

from cmv-app.

DavidSpriggs avatar DavidSpriggs commented on June 12, 2024

In the code above, you need to use "new" when creating the geometry service object. Actually, this code is not need for two reasons:

  1. As a general rule, you do not want to create a new geometry service object every time you get your position. Instead, create it once and use it many times (see below).
  2. The app already has a geometry service object created. It's url is set in the config file and then gets created at: esri.config.defaults.geometryService (see the initConfig method in the controller.js file).

from cmv-app.

kgerhartz avatar kgerhartz commented on June 12, 2024

So how is it referenced in the modules? Does it need to be added or is it just "available" as in being able to view it's URL like alert(GeometryService.url);. This learning curve is killing me :-(

from cmv-app.

kgerhartz avatar kgerhartz commented on June 12, 2024

Still trying to get this to work. Geometry service is returning properly projected point but can't get it to center and zoom.

    locationSuccess: function (event) {

        this.graphics.clear();
        var point = new esri.geometry.Point(event.coords.longitude, event.coords.latitude, new SpatialReference({ 
            wkid: 4326
        }));

        var outSR = new esri.SpatialReference({wkid: this.map.spatialReference.wkid});
        esri.config.defaults.geometryService.project([point], outSR, function (features){     
            pt = features[0];
            //console.log("gsvc returned: ", pt);
            this.map.centerAndZoom(pt, 3);
        });

......

from cmv-app.

DavidSpriggs avatar DavidSpriggs commented on June 12, 2024

@kgerhartz The issue above is that your project callback is not bound to the proper scope when it returns (no reference to the map object). To fix this you would use a lang.hitch(this, callback). Read here for more details: http://dojotoolkit.org/reference-guide/1.8/dojo/_base/lang.html#dojo-base-lang-hitch

I have committed code to handle the project (1339a47) have a look at the GeoLocation.js

from cmv-app.

kgerhartz avatar kgerhartz commented on June 12, 2024

That helped a lot in terms of understanding more about OO aspect. Thanks for your patience.

from cmv-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.