POST
|
Jake & Vara, Thank you so much for your help. I used Jake's code, tweaked it and got what I wanted. Almost. The last thing I wanted to do with these textSymbols was color them with a Class Breaks Renderer. However, looking at the sample on API Reference page, and the code I'm using, I could not see where to plug the new renderer in. What am I missing? Charles
... View more
06-20-2014
07:49 PM
|
0
|
0
|
373
|
POST
|
You can zip up the code and CSV file, and then upload the zip file. Jake, Should be there. Thanks for taking the time to look at it. Charles
... View more
06-16-2014
12:09 PM
|
0
|
0
|
373
|
POST
|
Hi Charles, When are you calling this function? Can you post your code and possibly the CSV file you are using? Hi Jake, I cant post the code due to the length. Is there another way I can get it to you and long with the CSV file? Can I email it to you? The majority of the data used is on a local intranet thus I cant post it on Jfiddle as the data will be inaccessible. Below is a snippet.
//Add Latest RiverStages CSV Layers
var riverCSVtemplate = new InfoTemplate();
riverCSVtemplate.setContent(getriverCSVTextContent);
var LatestRiverStages = new CSVLayer("symGSPHydroViewer/data/riverquery.csv",{id:"LatestRiverStages",mode: FeatureLayer.MODE_SELECTION,outFields: ["*"],infoTemplate: riverCSVtemplate});
console.log("HERE1");
LatestRiverStages.on("update-end", function(results){
var textLayer = new GraphicsLayer();
console.log("HERE2");
arrayUtils.forEach(results.target.graphics, function(feature, index){
console.log("HERE3");
var geom = feature.geometry;
var displayText = feature.attributes.value;
var font = new Font(
"12pt",
Font.STYLE_NORMAL,
Font.VARIANT_NORMAL,
Font.WEIGHT_BOLD,
"Helvetica"
);
var textSymbol = new TextSymbol(
displayText,
font,
new Color("#DC143C")
);
textLayer.add(new Graphic(geom, textSymbol));
});
map.addLayer(textLayer);
});
console.log("HERE4");
var blank = new Color([0, 0, 0, 0]); // hex is #ff4500
var marker = new SimpleMarkerSymbol("solid", 0, null, blank);
var renderer = new SimpleRenderer(marker);
LatestRiverStages.setRenderer(renderer);
map.addLayer(LatestRiverStages);
console.log("HERE5");
function getriverCSVTextContent (graphic) {
console.log("sample");
var attributes = graphic.attributes;
var value = "Obs Value: " + attributes.value;
var validtime = "Valid Time: " + attributes.validtime;
return value + "</b><br />" + validtime
}
... View more
06-16-2014
11:58 AM
|
0
|
0
|
726
|
POST
|
Jake, So I noticed that I was using arrayUtils vs array, I so I switched the array call to arrayUtils and the values plotted. However, using the below code, I was not able to sample the graphic.
function getriverCSVTextContent (graphic) {
var attributes = graphic.attributes;
var value = "Obs Value: " + attributes.value;
var validtime = "Valid Time: " + attributes.validtime;
return value + "</b><br />" + validtime
}
... View more
06-13-2014
01:25 PM
|
0
|
0
|
726
|
POST
|
Thank you so much for the reply. I tried to implement the code you provided but for some reason it does not seem to be entering the Arrayutils function. I printed some text to console to see where it was failing and that seems to be the place. I triple checked to make sure I had all the needed modules pulled in at the top. Any ideas?
//Add Latest RiverStages CSV Layers
var riverCSVtemplate = new InfoTemplate();
riverCSVtemplate.setContent(getriverCSVTextContent);
var LatestRiverStages = new CSVLayer("symGSPHydroViewer/data/riverquery.csv",{id:"LatestRiverStages",mode: FeatureLayer.MODE_SELECTION,outFields: ["*"],infoTemplate: riverCSVtemplate});
console.log("HERE1");
LatestRiverStages.on("update-end", function(results){
var textLayer = new GraphicsLayer();
console.log("HERE2");
array.forEach(results.target.graphics, function(feature, index){
console.log("HERE3");
var geom = feature.geometry;
var displayText = feature.attributes.value;
var font = new Font(
"12pt",
Font.STYLE_NORMAL,
Font.VARIANT_NORMAL,
Font.WEIGHT_BOLD,
"Helvetica"
);
var textSymbol = new TextSymbol(
displayText,
font,
new Color("#DC143C")
);
textLayer.add(new Graphic(geom, textSymbol));
});
map.addLayer(textLayer);
});
console.log("HERE4");
var blank = new Color([0, 0, 0, 0]); // hex is #ff4500
var marker = new SimpleMarkerSymbol("solid", 0, null, blank);
var renderer = new SimpleRenderer(marker);
LatestRiverStages.setRenderer(renderer);
map.addLayer(LatestRiverStages);
console.log("HERE5");
Hi Charles, Using the 'update-end' event for the CSVLayer class, I was able to obtain the feature's attributes, and then use this as a TextSymbol. Here is the code I used: var map, csv;
require([
"esri/map",
"esri/layers/CSVLayer",
"esri/Color",
"esri/graphic",
"esri/layers/GraphicsLayer",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/InfoTemplate",
"esri/urlUtils",
"esri/symbols/Font",
"esri/symbols/TextSymbol",
"dojo/on",
"dojo/_base/array",
"dojo/domReady!"
], function(
Map, CSVLayer, Color,
Graphic, GraphicsLayer,
SimpleMarkerSymbol, SimpleRenderer,
InfoTemplate, urlUtils, Font, TextSymbol,
on, array
) {
urlUtils.addProxyRule({
proxyUrl: "http://server1/proxy/proxy.ashx",
urlPrefix: "skinner-lap"
});
map = new Map("map", {
basemap: "gray",
center: [ -60, -10 ],
zoom: 4
});
csv = new CSVLayer("http://server1/UserData/2.5_week.csv", {
copyright: "USGS.gov"
});
csv.on("update-end", function(results){
var textLayer = new GraphicsLayer();
array.forEach(results.target.graphics, function(feature, index){
var geom = feature.geometry;
var displayText = feature.attributes.id;
var font = new Font(
"12pt",
Font.STYLE_NORMAL,
Font.VARIANT_NORMAL,
Font.WEIGHT_BOLD,
"Helvetica"
);
var textSymbol = new TextSymbol(
displayText,
font,
new Color("#DC143C")
);
textLayer.add(new Graphic(geom, textSymbol));
});
map.addLayer(textLayer);
});
var blank = new Color([0, 0, 0, 0]); // hex is #ff4500
var marker = new SimpleMarkerSymbol("solid", 0, null, blank);
var renderer = new SimpleRenderer(marker);
csv.setRenderer(renderer);
map.addLayer(csv);
});
... View more
06-13-2014
12:34 PM
|
0
|
0
|
726
|
POST
|
Just wanted to bump this back to the top. Still looking for an answer.
... View more
06-10-2014
09:45 AM
|
0
|
0
|
726
|
POST
|
Just wanted to bump this back to the top. Still looking for an answer.
... View more
06-09-2014
03:35 AM
|
0
|
0
|
726
|
POST
|
Thanks Heath, What a bummer. I wish there was a better solution. How do you create a Map Service for a KMZ since you can directly load that into ArcMap, can you? Danny
... View more
06-04-2014
02:37 AM
|
0
|
0
|
575
|
POST
|
So here is the code I currently have. The issue is that I'm not pulling in the "value" attribute field. With this code, it just plots a TextSymbol of the word "value". I know this is the correct method for using a label layer, but as said above I cant use that since I need to be able to use the popup widget on the graphics layer. Can anyone help me out?
//Add Latest RiverStages CSV Layers
var riverCSVtemplate = new InfoTemplate();
riverCSVtemplate.setContent(getriverCSVTextContent);
var LatestRiverStages = new CSVLayer("./data/riverquery.csv",{id:"LatestRiverStages",mode: FeatureLayer.MODE_SELECTION,outFields: ["*"],infoTemplate: riverCSVtemplate});
var Green = new Color([0, 255, 0, 1.0]);
var labelField = "value";
var symbol = new TextSymbol();
symbol.setAlign = TextSymbol.ALIGN_MIDDLE;
var font = new Font();
font.setSize("8pt");
font.setWeight(Font.WEIGHT_BOLD);
symbol.setFont(font)
symbol.setText("${" + labelField + "}")
symbol.setColor(new Color(Green));
var renderer = new SimpleRenderer(symbol);
LatestRiverStages.setRenderer(renderer);
map.addLayer(LatestRiverStages);
// LatestRiverStages.hide();
... View more
06-04-2014
01:14 AM
|
0
|
0
|
726
|
POST
|
Hello, I've been trying to figure this out for about two days now. I have a CSVLayer that I'm plotting using a standard marker symbol. I have to use a symbol because I need to be able to sample the points as a graphic layer for the popup widget. Which all works fine. However, I need to NOT plot a simple marker symbol, I need the symbol to be a TextSymbol that is one of the attribute fields of the CSVLayer. I cannot find a good example online anywhere. This doesn't seem like it should be this hard. Does anyone have an example or can tell me where to find an applicable example? Thanks in advance!
... View more
06-02-2014
01:31 AM
|
0
|
16
|
2038
|
POST
|
All, Three questions: 1. Can I create a raster dataset from a point shapefile or a CSV in the API? If so, where do I start? 2. Is there a method such as "Extract data from points" like in Arcmap for the API? 3. Is there an intersect tool? I have a dataset, and a polygon shapefile. I need to be able to interpolate the dataset, and somehow apply the correct data from the dataset to the apporiate shape that lies underneath from the polygon shapefile. Thanks in advance!
... View more
05-29-2014
08:15 AM
|
0
|
0
|
626
|
POST
|
mine obey visibility. Make sure you arent grouping layers in your mapservice, TOC can't handle groups Jeff, As you can see they are not grouped. When you say "obey visibility", are you setting the layers invisible when you declare, or like the method I'm using below?
//Use the ImageParameters to set the invisible layers in the map service during ArcGISDynamicMapServiceLayer construction.
var imageParameters = new ImageParameters();
imageParameters.layerIds = [0,1];
imageParameters.layerOption = ImageParameters.LAYER_OPTION_INCLUDE;
//can also be: LAYER_OPTION_EXCLUDE, LAYER_OPTION_HIDE, LAYER_OPTION_INCLUDE
//Takes a URL to a non cached map service.
var dynamicMapServiceLayer0 = new ArcGISDynamicMapServiceLayer("http://atlas.resources.ca.gov/ArcGIS/rest/services/Atmosphere_Climate/RIDGE_Precip_Radar/MapServer/", {
"opacity" : 0.5,"imageParameters":imageParameters});
//Takes a URL to a non cached map service.
var dynamicMapServiceLayer1 = new ArcGISDynamicMapServiceLayer("http://gisdev.srh.noaa.gov/arcgis/rest/services/GSP/gffg/MapServer", {
"opacity" : 0.5,"imageParameters":imageParameters});
map.addLayer(dynamicMapServiceLayer0);
map.addLayer(dynamicMapServiceLayer1);
... View more
05-27-2014
12:44 PM
|
0
|
0
|
554
|
POST
|
http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/docs/toc/reference.html Jeff, Do you know how to set all the layers to "un-check" by default? I have the layers hidden, so they don't show, but the boxes in the TOC are check and for them to work you have to "un-check" and "re-check" them. Thanks!
... View more
05-27-2014
10:49 AM
|
0
|
0
|
554
|
Title | Kudos | Posted |
---|---|---|
1 | 05-04-2012 06:30 PM | |
1 | 05-13-2012 06:45 AM | |
1 | 05-17-2014 01:34 PM | |
1 | 05-02-2015 03:51 AM | |
1 | 05-07-2015 03:54 AM |
Online Status |
Offline
|
Date Last Visited |
03-04-2022
02:18 PM
|