Comments (7)
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.
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.
In the code above, you need to use "new" when creating the geometry service object. Actually, this code is not need for two reasons:
- 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).
- 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.
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.
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.
@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.
That helped a lot in terms of understanding more about OO aspect. Thanks for your patience.
from cmv-app.
Related Issues (20)
- field value should contain hyperlink in a popup obtain from search widget in 2.8 versionWeb App builder developer edition
- Removing infoTemplate on setMapClickMode HOT 2
- Create Dialog Box Dynamically,Get user input values and Add Text Graphics on Map ? HOT 1
- vector tile service 4.x supported? HOT 2
- Toggle Labeling menu LayerControl widget Layers ? HOT 5
- Can only identify top layer in Grouped Layer configuration HOT 5
- add WMS-C layer
- Print Scale Error HOT 3
- can cmv be localized??? HOT 4
- example to use Arcade in a customized identify config file HOT 2
- Feature Server support?
- support arcgis javascript api v3.33? or v3.28 HOT 4
- Are you going to make v4.16 version of CMV? v3.x will retired in 2022 as ESRI claimed HOT 4
- Save Layer Visibility State in URL Query Params HOT 2
- How put an accordion in left pane HOT 2
- BUG? - LayerControl doesn´t show all simbology
- Doubt: how open sidebarBottom programatically? HOT 1
- Zoom Level in Attribute Grid HOT 1
- Missing iconClass in widget config causes crash while loading on mobile HOT 1
- Home Button bug HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmv-app.