Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic layer identifies for sublayer id 0 #706

Merged
merged 7 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions viewer/js/config/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ define([
text: 'Get Directions'
});
}

/**
* A simple number formatter that adds commas to a number
* @param {number} num The number to commafy
* @return {String} The formatted number
*/
function commafy (num) {
var str = num.toString().split('.');
if (str[0].length >= 5) {
str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
if (str[1] && str[1].length >= 5) {
str[1] = str[1].replace(/(\d{3})/g, '$1 ');
}
return str.join('.');
}


return {
map: true,
mapClickMode: true,
Expand All @@ -34,6 +52,20 @@ define([
// for details on pop-up definition see: https://developers.arcgis.com/javascript/jshelp/intro_popuptemplate.html

identifies: {
cities: {
0: {
fieldInfos: [{
visible: true,
fieldName: 'CITY_NAME',
label: 'Name'
}, {
visible: true,
fieldName: 'POP',
label: 'Population',
formatter: commafy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't dojo's number.format be a better practice to promote - automatically handling differences based on locale?

}]
}
},
louisvillePubSafety: {
2: {
title: i18n.identify.louisvillePubSafety.policeStation,
Expand Down
1 change: 1 addition & 0 deletions viewer/js/config/nls/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ define({
},
viewer: {
operationalLayers: {
cities: 'World Cities',
damageAssessment: 'Damage Assessment',
louisvillePubSafety: 'Louisville Public Safety',
restaurants: 'Restaurants',
Expand Down
8 changes: 8 additions & 0 deletions viewer/js/config/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ define([
iconClass: 'fa fa-smile-o'
}]
}
}, {
type: 'dynamic',
url: 'http://sampleserver6.arcgisonline.com/arcgis/rest/services/SampleWorldCities/MapServer',
title: i18n.viewer.operationalLayers.cities,
options: {
id: 'cities',
visible: false
}
}, {
type: 'dynamic',
url: 'https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyOperationalLayers/MapServer',
Expand Down
2 changes: 1 addition & 1 deletion viewer/js/gis/dijit/Identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ define([
getInfoTemplate: function (layer, layerId, result) {
var popup, config;
if (result) {
layerId = result.layerId || layer.layerId;
layerId = typeof result.layerId === 'number' ? result.layerId : layer.layerId;
} else if (layerId === null) {
layerId = layer.layerId;
}
Expand Down