|
POST
|
True, for my purposes I don't need it. Jatin did add this bit which should add attributes. var fieldAttributes = {}; fieldAttributes["tech"] = "Zach"; fieldAttributes["MeterNumber"] = 1234; . . . . var newFeature = new esri.Graphic(geometry, null, fieldAttributes); featureLayer.applyEdits([newFeature], null, null, function () {//success}, function() {//error});
... View more
04-29-2014
08:37 AM
|
0
|
0
|
1140
|
|
POST
|
var newFeature = new esri.Graphic(geometry, null,null);
featureLayer.applyEdits([graphic], null, null); This is the change that adds the point feature layer...
... View more
04-29-2014
06:24 AM
|
0
|
0
|
1140
|
|
POST
|
Sure thing. It is a little hinky on the geometry, but it does place a point. <script>
var map;
var graphic;
var currLocation;
var watchId;
require([
"esri/map", "esri/geometry/Point","esri/layers/FeatureLayer",
"esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol",
"esri/graphic", "esri/Color", "dojo/domReady!"
], function bat(
Map, Point,FeatureLayer,
SimpleMarkerSymbol, SimpleLineSymbol,
Graphic, Color
) {
map = new Map("map", {
basemap: "oceans",
center: [-85.957, 17.140],
zoom: 11
});
var featureLayer = new FeatureLayer("", {
mode: FeatureLayer.MODE_SELECTION,
outFields: ["*"]
});
map.addLayer(featureLayer);
map.on("load", initFunc);
function orientationChanged() {
if(map){
map.reposition();
map.resize();
}
}
function initFunc(map) {
if( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition(zoomToLocation, locationError);
watchId = navigator.geolocation.watchPosition(showLocation, locationError);
} else {
alert("Browser doesn't support Geolocation. Visit http://caniuse.com to see browser support for the Geolocation API.");
}
}
function locationError(error) {
//error occurred so stop watchPosition
if( navigator.geolocation ) {
navigator.geolocation.clearWatch(watchId);
}
switch (error.code) {
case error.PERMISSION_DENIED:
alert("Location not provided");
break;
case error.POSITION_UNAVAILABLE:
alert("Current location not available");
break;
case error.TIMEOUT:
alert("Timeout");
break;
default:
alert("unknown error");
break;
}
}
function zoomToLocation(location) {
var pt = new Point(location.coords.longitude, location.coords.latitude);
addGraphic(pt);
map.centerAndZoom(pt, 12);
}
function showLocation(location) {
//zoom to the users location and add a graphic
var pt = new Point(location.coords.longitude, location.coords.latitude);
if ( !graphic ) {
addGraphic(pt);
} else { // move the graphic if it already exists
graphic.setGeometry(pt);
}
map.centerAt(pt);
}
var geometry;
function addGraphic(pt){
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE,
12);
graphic = new Graphic(pt, symbol);
map.graphics.add(graphic);
new esri.geometry.Point(pt, map.spatialReference);
var newFeature = new esri.Graphic(geometry, null,null);
featureLayer.applyEdits([newFeature], null, null, function () {}, function() {});
}
});
</script>
... View more
04-29-2014
06:00 AM
|
0
|
0
|
1140
|
|
POST
|
It will be a point on layer. The concept is to add water utility service orders to a feature layer by our service technicians (zach). From there it will go back to our server to be processed on ArcMap. We were initially going to have them place it manually with Editor, but we need more accuracy. Any ideas?
... View more
04-28-2014
12:39 PM
|
0
|
0
|
1583
|
|
POST
|
Your help is very much appreciated, but I have one tiny, little question. How do I tie in the graphic to push the point to the feature layer? function addGraphic(pt){
var symbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE,
12);
graphic = new Graphic(pt, symbol);
map.graphics.add(graphic);
// zach is feature layer
map.zach.add(graphic);
new esri.geometry.Point(pt, map.spatialReference); Pardon my incompetence, I'm transferring over from Flex.
... View more
04-28-2014
12:16 PM
|
0
|
0
|
1583
|
|
POST
|
This is in the ball park, but I need to add the point to a feature database based on the gps lat lon.(Should have been more specific) I have the geolocation down, but adding the feature point is giving me the guff.(I'm very, very new to this... Should have mentioned that) Do I need to use an editor or draw function?
... View more
04-28-2014
11:02 AM
|
0
|
0
|
1583
|
|
POST
|
I am trying to create an app to add a feature layer point at a users location. I haven't had much luck finding a good example. Ideally, this should function like Collector for ArcGIS, where as the user clicks to collect a feature at the lat/long. Can anybody help in finding resource material pertaining to adding a single feature to the map/SDE. I've sifted through a lot of material, but haven't found any pay dirt. Thanks
... View more
04-28-2014
08:59 AM
|
0
|
17
|
3080
|
|
POST
|
Crap, I think I might have left out some parts. Here is the full code(service omitted). <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Popup</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/dojo/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"/>
<style>
html,body,#map{
padding:0;
margin:0;
height:100%;
}
</style>
<script src="http://js.arcgis.com/3.8/"></script>
<script>
require([
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/symbols/SimpleMarkerSymbol",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/tasks/query", "esri/tasks/QueryTask",
"dojo/dom-class",
"dojo/dom-construct",
"dijit/layout/ContentPane",
"dojo/on",
"dojox/charting/Chart",
"dojox/charting/themes/Dollar",
"dojo/domReady!"
], function(
Map,
Popup,
PopupTemplate,
FeatureLayer,
SimpleMarkerSymbol,
Dynamic,
Query,QueryTask,
domClass,
domConstruct,
ContentPane,
on,
Chart,
theme
){
//The popup is the default info window so you only need to create the popup and
//assign it to the map if you want to change default properties. Here we are
//noting that the specified title content should display in the header bar
var popup = Popup({
titleInBody: false
},domConstruct.create("div"));
var map = new Map("map", {
basemap: "satellite",
center: [-88.595, 38.937],
zoom: 11,
infoWindow: popup
});
//define the popup content using a popup template
//a custom chart theme (dollar) is specified. Note that you'll have to load
//then theme first
var template = new esri.InfoTemplate();
template.setTitle("Billing");
//template.setContent("hello");
template.setContent(getTextContent);
var imageParams = new esri.layers.ImageParameters();
imageParams.layerIds = [0,1];
imageParams.layerOption = esri.layers.ImageParameters.LAYER_OPTION_SHOW;
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("Secure service", {imageParameters:imageParams});
map.addLayer(dynamicMapServiceLayer);
var selectionSymbol = new esri.symbol.SimpleMarkerSymbol().setColor("red");
wellFeatureLayer = new esri.layers.FeatureLayer("Secure service", {
mode: esri.layers.FeatureLayer.MODE_SELECTION,
//infoTemplate: new esri.InfoTemplate("Well Well: ${OBJECTID_1}","${OBJECTID_1}")
infoTemplate: template
});
map.addLayers([dynamicMapServiceLayer]);
dojo.connect(wellFeatureLayer, "onSelectionComplete", findRelatedRecords);
map.addLayer(wellFeatureLayer);
dojo.connect(map, "onClick", findWells);
dojo.addClass(map.infoWindow.domNode, "myTheme");
function getTextContent(graphic){
return "<b>" + "OBJECTID: " + items[0].ESRI_OID + "</b><br/>" + "First Name: " + items[0].CUSTNAME + "</b><br/>" + "Address: " + items[0].ADDR1;
}
function findRelatedRecords(features) {
var relatedTopsQuery = new esri.tasks.RelationshipQuery();
relatedTopsQuery.outFields = ["*"];
//relatedTopsQuery.relationshipId = 3;
relatedTopsQuery.relationshipId = 0;
//relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
console.log("related recs: ", relatedRecords);
if ( ! relatedRecords.hasOwnProperty(features[0].attributes.OBJECTID) ) {
console.log("No related records for ObjectID_1: ", features[0].attributes.OBJECTID_1);
return;
}
var fset = relatedRecords[features[0].attributes.OBJECTID];
//var fset = relatedRecords[features[0].attributes.OBJECTID];
items = dojo.map(fset.features, function(feature) {
return feature.attributes;
});
var data = {
identifier: "OBJECTID", //This field needs to have unique values
label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
});
}
function findWells(evt) {
var selectionQuery = new esri.tasks.Query();
var tol = map.extent.getWidth()/map.width * 5;
var x = evt.mapPoint.x;
var y = evt.mapPoint.y;
var queryExtent = new esri.geometry.Extent(x-tol,y-tol,x+tol,y+tol,evt.mapPoint.spatialReference);
selectionQuery.geometry = queryExtent;
wellFeatureLayer.selectFeatures(selectionQuery,esri.layers.FeatureLayer.SELECTION_NEW);
}
;
})
;
</script>
</head>
<body class="claro">
<div id="map"></div>
</body>
</html>
... View more
04-19-2014
05:45 AM
|
0
|
0
|
984
|
|
POST
|
Update: Thanks to Noah we were able to get the related table into an info window . Query function findRelatedRecords(features) {
var relatedTopsQuery = new esri.tasks.RelationshipQuery();
relatedTopsQuery.outFields = ["*"];
//relatedTopsQuery.relationshipId = 3;
relatedTopsQuery.relationshipId = 0;
//relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
console.log("related recs: ", relatedRecords);
if ( ! relatedRecords.hasOwnProperty(features[0].attributes.OBJECTID) ) {
console.log("No related records for ObjectID_1: ", features[0].attributes.OBJECTID_1);
return;
}
var fset = relatedRecords[features[0].attributes.OBJECTID];
//var fset = relatedRecords[features[0].attributes.OBJECTID];
items = dojo.map(fset.features, function(feature) {
return feature.attributes;
});
var data = {
identifier: "OBJECTID", //This field needs to have unique values
label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
}; Function to pull info function getTextContent(graphic){
return "<b>" + "OBJECTID: " + items[0].ESRI_OID + "</b><br/>" + "First Name: " + items[0].CUSTNAME + "</b><br/>" + "Address: " + items[0].ADDR1;
} Template var template = new esri.InfoTemplate();
template.setTitle("Billing");
template.setContent(getTextContent); This only pulls designated fields, but it is an acceptable workaround for me...
... View more
04-16-2014
01:49 PM
|
0
|
0
|
984
|
|
POST
|
Hi David, I've been on the same issue with support for almost a month. This is about as far as we got. It will pull records(can be seen in the console) but getting it into an info window is perplexing us both. If you get any luck on your end could you post it. function findRelatedRecords(features) {
var relatedTopsQuery = new esri.tasks.RelationshipQuery();
relatedTopsQuery.outFields = ["*"];
relatedTopsQuery.relationshipId = 0;
relatedTopsQuery.objectIds = [features[0].attributes.OBJECTID];
wellFeatureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
console.log("related recs: ", relatedRecords);
if ( ! relatedRecords.hasOwnProperty(features[0].attributes.OBJECTID) ) {
console.log("No related records for ObjectID: ", features[0].attributes.OBJECTID);
return;
}
alert("Account Number: " + relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.ACCTNUM);
alert("Address: " + relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.ADDR1);
alert("City & State: " + relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.CITYSTATE);
alert("Phone Number: " + relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.PHONE);
console.log(relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.ACCTNUM);
console.log(relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.ADDR1);
console.log(relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.CITYSTATE);
console.log(relatedRecords[features[0].attributes.OBJECTID].features[0].attributes.PHONE);
... View more
04-16-2014
06:59 AM
|
0
|
0
|
984
|
|
POST
|
Hey guys, This is a really easy one, but I'm negligent when it comes to syntax. I'm trying to do a basic attribute inspector with multiple layers. function initSelectToolbar(evt) {
var petroFieldsFL = evt.layers[0].layer;
var selectQuery = new Query();
map.on("click", function(evt) {
selectQuery.geometry = evt.mapPoint;
/** TM Calculating tolerance for point **/
var centerPoint = new esri.geometry.Point
(evt.mapPoint.x,evt.mapPoint.y,evt.mapPoint.spatialReference);
var mapWidth = map.extent.getWidth();
//Divide width in map units by width in pixels
var pixelWidth = mapWidth/map.width;
//Calculate a 10 pixel envelope width (5 pixel tolerance on each side)
var tolerance = 10 * pixelWidth;
var x = evt.mapPoint.x;
var y = evt.mapPoint.y;
//Build tolerance envelope and set it as the query geometry
var queryExtent = new esri.geometry.Extent
(x-tolerance, y-tolerance,x+tolerance,y+tolerance,evt.mapPoint.spatialReference);
selectQuery.geometry = queryExtent;
petroFieldsFL.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function(features) {
//store the current feature
updateFeature = features[0];
map.infoWindow.setTitle(features[0].getLayer().name);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
});
});
map.infoWindow.on("hide", function() {
petroFieldsFL.clearSelection();
});
var layerInfos = [{
'featureLayer': petroFieldsFL,
'showAttachments': false,
'isEditable': true,
'fieldInfos': [
{'fieldName': 'SERVICE_ID', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'FIRSTNAME', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'LAST_NAME', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'CITYSTATE', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'ZIPCODE', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'TOWNSHIP', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'COUNTY', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'LOCATION', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'PHONE', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'METERLOCATION2', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'AMR', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'SHEET', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'PHASE_1', 'isEditable':false, 'tooltip': 'Current Status', 'label':'Status:'}
]
},
{
'featureLayer': petroFieldsFL1,
'showAttachments': false,
'isEditable': true,
'fieldInfos': ["*"]
}
];
var attInspector = new AttributeInspector({
layerInfos:layerInfos
},
I've tried many variations but it always comes up with one layer or the other or neither. Changing the fieldInfos to "*" seemed to have that effect. Any ideas as to the location of my bludering?
... View more
04-14-2014
01:44 PM
|
0
|
0
|
937
|
|
POST
|
I recently made the transition myself. My advice is to learn up on javascript syntax as much as possible. Code academy or another training site would be a good time investment just to get brushed up. I didn't take this step and it bit me in the ass. Be weary of mixing AMD and Legacy, this also cost me time. Working with Flex was a lot easier. JS is a finicky mistress. Good Luck
... View more
04-14-2014
12:25 PM
|
0
|
0
|
705
|
|
POST
|
Paydirt!! The log showed "FIRSTNAMELIKE '%ted%'" so I inserted an extra space in the " LIKE '%" to make it "FIRSTNAME LIKE '%ted%'"... Thanks, you guys have restored my faith in humanity.
... View more
04-10-2014
03:56 AM
|
0
|
0
|
396
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-25-2015 09:25 AM | |
| 1 | 08-26-2015 05:13 AM | |
| 1 | 08-27-2015 08:59 AM | |
| 1 | 04-13-2015 12:06 PM | |
| 1 | 02-03-2015 07:29 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-05-2023
04:48 PM
|