Esri API JS, popup not displaying after first click Planned maintenance scheduled April 23,...

The Nth Gryphon Number

Any stored/leased 737s that could substitute for grounded MAXs?

Did pre-Columbian Americans know the spherical shape of the Earth?

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

Is the time—manner—place ordering of adverbials an oversimplification?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

Who said what about *meanings*?

latest version of QGIS fails to edit attribute table of GeoJSON file

Keep at all times, the minus sign above aligned with minus sign below

Flight departed from the gate 5 min before scheduled departure time. Refund options

What does 丫 mean? 丫是什么意思?

malloc in main() or malloc in another function: allocating memory for a struct and its members

As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?

What is the proper term for etching or digging of wall to hide conduit of cables

What are some likely causes to domain member PC losing contact to domain controller?

How do you write "wild blueberries flavored"?

Short story about astronauts fertilizing soil with their own bodies

.bashrc alias for a command with fixed second parameter

How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?

Inverse square law not accurate for non-point masses?

Can gravitational waves pass through a black hole?

Does the transliteration of 'Dravidian' exist in Hindu scripture? Does 'Dravida' refer to a Geographical area or an ethnic group?

How do Java 8 default methods hеlp with lambdas?

3D Masyu - A Die



Esri API JS, popup not displaying after first click



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Basemap Gallery Error - ESRI JS APITrouble with accesing API code: “ReferenceError: esri is not defined”Redraw info window after centering map on click (ESRI Javascript API)Simulate a click event on FeatureLayer in ESRI JavaScript APIProject Point using ArcGIS API for JavaScript?ESRI JavaScript API FeatureLayer Click EventTabs in ESRI PopupPopup Not Displaying in ArcGIS API for JavaScript 3?How to prevent map click event esri map js API?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















Demographics data shows upon first click but not after, park information does work. I've changed around almost everything with non real solution. I feel like for whatever reason my feature server data is preferred over the dynamiclayer in the map. Is there a way to make the js bounce based on where you click?



    var map;

require([
"esri/config",
"esri/InfoTemplate",
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/GeometryService",
"esri/tasks/query",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/parser",
"esri/Color",
"dojo/_base/lang",
"dojo/date/locale",
"esri/dijit/Geocoder",
"esri/dijit/LocateButton",
"dojo/domReady!"
],
function (
esriConfig, InfoTemplate, Map, Popup, PopupTemplate, Extent, ArcGISDynamicMapServiceLayer, FeatureLayer,
ArcGISTiledMapServiceLayer, SimpleFillSymbol, SimpleLineSymbol,
GeometryService, Query, domConstruct, domClass, parser, Color, lang, locale, Geocoder, LocateButton
) {

parser.parse();


var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 0]), 2), new Color([128, 128, 128, 0.25]))
}, domConstruct.create("div"));

domClass.add(popup.domNode, "myTheme");

map = new Map("map", {
basemap: "topo",
center: [-122.402, 47],
zoom: 9,
infoWindow: popup
});

var geocoder = new Geocoder({
arcgisGeocoder: {
placeholder: "Search "
},
map: map
}, "ui-esri-dijit-geocoder");

var _countyCensusInfoTemplate = new InfoTemplate();
_countyCensusInfoTemplate.setTitle("<b>Census Information</b>");

var _blockGroupInfoTemplate = new InfoTemplate();
_blockGroupInfoTemplate.setTitle("<b>Census Information</b>");

var _censusInfoContent =
"<div class="demographicInfoContent">" +
"<div class='demographicNumericPadding'>${AGE_5_17:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 5 - 17<br>" +
"<div class='demographicNumericPadding'>${AGE_18_21:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 18 - 21<br>" +
"<div class='demographicNumericPadding'>${AGE_22_29:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 22 - 29<br>" +
"<div class='demographicNumericPadding'>${AGE_30_39:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 30 - 39<br>" +
"<div class='demographicNumericPadding'>${AGE_40_49:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 40 - 49<br>" +
"<div class='demographicNumericPadding'>${AGE_50_64:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 50 - 64<br>" +
"<div class='demographicNumericPadding'>${AGE_65_UP:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 65 and older" +
"</div>";

_countyCensusInfoTemplate.setContent("Demographics for:<br>${NAME} ${STATE_NAME:getCounty}, ${STATE_NAME}<br>" + _censusInfoContent);
_blockGroupInfoTemplate.setContent("Demographics for:<br>Tract: ${TRACT:formatNumber} Blockgroup: ${BLKGRP}<br>" + _censusInfoContent);

var demographicsLayerURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
var demographicsLayerOptions = {
"id": "demographicsLayer",
"opacity": 0.8,
"showAttribution": false
};

var demographicsLayer = new ArcGISDynamicMapServiceLayer(demographicsLayerURL, demographicsLayerOptions);
demographicsLayer.setInfoTemplates({
1: { infoTemplate: _blockGroupInfoTemplate },
2: { infoTemplate: _countyCensusInfoTemplate }
});
demographicsLayer.setVisibleLayers([1, 2]);
map.addLayer(demographicsLayer);

geocoder.startup();

var geoLocate = new LocateButton({
map: map,
highlightLocation: false
}, "LocateButton"
);
geoLocate.startup();

var formatNumber = function(value, key, data) {
var searchText = "" + value;
var formattedString = searchText.replace(/(d)(?=(ddd)+(?!d))/gm, "$1,");
return formattedString;
};

var getCounty = function(value, key, data) {
if (value.toUpperCase() !== "LOUISIANA") {
return "County";
} else {
return "Parish";
}
};

map.on("click", function (event) {
var query = new Query();
query.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = featureLayer.selectFeatures(query,
FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
});

var template = new InfoTemplate();
template.setTitle("Park Information");
template.setContent(getTextContent);

var featureLayer = new FeatureLayer("https://services3.arcgis.com/J1Locv0GPOt6yBRR/ArcGIS/rest/services/Parks_polygons_Feb2012/FeatureServer/0",
{
outFields: ["*"],
infoTemplate: template
});

map.addLayer(featureLayer);

function getTextContent (graphic) {
var attributes = graphic.attributes;
var namepark =
attributes.ParkName
.replace('"', "")
.split("::")
.map(function (name) {
return lang.trim(name);
});

var parkdata = namepark[0];
var commonName = namepark[1];
var parks;

if (commonName) {
parks = "<b>" + commonName + "</b><br/>" +
"<i>" + parkdata + "</i>";
}
else {
parks = "<i>" + parkdata + "</i>";
}

return parks + "<br>" +
attributes.Owner + "<br>" +
attributes.ParkWebLin
}

function pointToExtent (map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleranceInMapCoords = toleranceInPixel * pixelWidth;
return new Extent(point.x - toleranceInMapCoords,
point.y - toleranceInMapCoords,
point.x + toleranceInMapCoords,
point.y + toleranceInMapCoords,
map.spatialReference);
}

});
</script>
</head>

<body class="claro">
<div id="map">
<div id="LocateButton"></div>
</div>
<div id="ui-esri-dijit-geocoder"></div>

</body>


link to is http://students.washington.edu/sbuffor/combined_census_parks.html










share|improve this question

























  • Cross-posted from stackoverflow.com/questions/34120616/…

    – PolyGeo
    Dec 8 '15 at 0:06






  • 1





    Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

    – PolyGeo
    Dec 8 '15 at 0:10











  • 2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

    – Tom
    Dec 8 '15 at 15:52











  • Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

    – Staley
    Dec 8 '15 at 17:44











  • This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

    – Staley
    Dec 8 '15 at 19:09


















0















Demographics data shows upon first click but not after, park information does work. I've changed around almost everything with non real solution. I feel like for whatever reason my feature server data is preferred over the dynamiclayer in the map. Is there a way to make the js bounce based on where you click?



    var map;

require([
"esri/config",
"esri/InfoTemplate",
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/GeometryService",
"esri/tasks/query",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/parser",
"esri/Color",
"dojo/_base/lang",
"dojo/date/locale",
"esri/dijit/Geocoder",
"esri/dijit/LocateButton",
"dojo/domReady!"
],
function (
esriConfig, InfoTemplate, Map, Popup, PopupTemplate, Extent, ArcGISDynamicMapServiceLayer, FeatureLayer,
ArcGISTiledMapServiceLayer, SimpleFillSymbol, SimpleLineSymbol,
GeometryService, Query, domConstruct, domClass, parser, Color, lang, locale, Geocoder, LocateButton
) {

parser.parse();


var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 0]), 2), new Color([128, 128, 128, 0.25]))
}, domConstruct.create("div"));

domClass.add(popup.domNode, "myTheme");

map = new Map("map", {
basemap: "topo",
center: [-122.402, 47],
zoom: 9,
infoWindow: popup
});

var geocoder = new Geocoder({
arcgisGeocoder: {
placeholder: "Search "
},
map: map
}, "ui-esri-dijit-geocoder");

var _countyCensusInfoTemplate = new InfoTemplate();
_countyCensusInfoTemplate.setTitle("<b>Census Information</b>");

var _blockGroupInfoTemplate = new InfoTemplate();
_blockGroupInfoTemplate.setTitle("<b>Census Information</b>");

var _censusInfoContent =
"<div class="demographicInfoContent">" +
"<div class='demographicNumericPadding'>${AGE_5_17:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 5 - 17<br>" +
"<div class='demographicNumericPadding'>${AGE_18_21:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 18 - 21<br>" +
"<div class='demographicNumericPadding'>${AGE_22_29:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 22 - 29<br>" +
"<div class='demographicNumericPadding'>${AGE_30_39:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 30 - 39<br>" +
"<div class='demographicNumericPadding'>${AGE_40_49:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 40 - 49<br>" +
"<div class='demographicNumericPadding'>${AGE_50_64:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 50 - 64<br>" +
"<div class='demographicNumericPadding'>${AGE_65_UP:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 65 and older" +
"</div>";

_countyCensusInfoTemplate.setContent("Demographics for:<br>${NAME} ${STATE_NAME:getCounty}, ${STATE_NAME}<br>" + _censusInfoContent);
_blockGroupInfoTemplate.setContent("Demographics for:<br>Tract: ${TRACT:formatNumber} Blockgroup: ${BLKGRP}<br>" + _censusInfoContent);

var demographicsLayerURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
var demographicsLayerOptions = {
"id": "demographicsLayer",
"opacity": 0.8,
"showAttribution": false
};

var demographicsLayer = new ArcGISDynamicMapServiceLayer(demographicsLayerURL, demographicsLayerOptions);
demographicsLayer.setInfoTemplates({
1: { infoTemplate: _blockGroupInfoTemplate },
2: { infoTemplate: _countyCensusInfoTemplate }
});
demographicsLayer.setVisibleLayers([1, 2]);
map.addLayer(demographicsLayer);

geocoder.startup();

var geoLocate = new LocateButton({
map: map,
highlightLocation: false
}, "LocateButton"
);
geoLocate.startup();

var formatNumber = function(value, key, data) {
var searchText = "" + value;
var formattedString = searchText.replace(/(d)(?=(ddd)+(?!d))/gm, "$1,");
return formattedString;
};

var getCounty = function(value, key, data) {
if (value.toUpperCase() !== "LOUISIANA") {
return "County";
} else {
return "Parish";
}
};

map.on("click", function (event) {
var query = new Query();
query.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = featureLayer.selectFeatures(query,
FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
});

var template = new InfoTemplate();
template.setTitle("Park Information");
template.setContent(getTextContent);

var featureLayer = new FeatureLayer("https://services3.arcgis.com/J1Locv0GPOt6yBRR/ArcGIS/rest/services/Parks_polygons_Feb2012/FeatureServer/0",
{
outFields: ["*"],
infoTemplate: template
});

map.addLayer(featureLayer);

function getTextContent (graphic) {
var attributes = graphic.attributes;
var namepark =
attributes.ParkName
.replace('"', "")
.split("::")
.map(function (name) {
return lang.trim(name);
});

var parkdata = namepark[0];
var commonName = namepark[1];
var parks;

if (commonName) {
parks = "<b>" + commonName + "</b><br/>" +
"<i>" + parkdata + "</i>";
}
else {
parks = "<i>" + parkdata + "</i>";
}

return parks + "<br>" +
attributes.Owner + "<br>" +
attributes.ParkWebLin
}

function pointToExtent (map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleranceInMapCoords = toleranceInPixel * pixelWidth;
return new Extent(point.x - toleranceInMapCoords,
point.y - toleranceInMapCoords,
point.x + toleranceInMapCoords,
point.y + toleranceInMapCoords,
map.spatialReference);
}

});
</script>
</head>

<body class="claro">
<div id="map">
<div id="LocateButton"></div>
</div>
<div id="ui-esri-dijit-geocoder"></div>

</body>


link to is http://students.washington.edu/sbuffor/combined_census_parks.html










share|improve this question

























  • Cross-posted from stackoverflow.com/questions/34120616/…

    – PolyGeo
    Dec 8 '15 at 0:06






  • 1





    Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

    – PolyGeo
    Dec 8 '15 at 0:10











  • 2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

    – Tom
    Dec 8 '15 at 15:52











  • Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

    – Staley
    Dec 8 '15 at 17:44











  • This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

    – Staley
    Dec 8 '15 at 19:09














0












0








0


0






Demographics data shows upon first click but not after, park information does work. I've changed around almost everything with non real solution. I feel like for whatever reason my feature server data is preferred over the dynamiclayer in the map. Is there a way to make the js bounce based on where you click?



    var map;

require([
"esri/config",
"esri/InfoTemplate",
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/GeometryService",
"esri/tasks/query",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/parser",
"esri/Color",
"dojo/_base/lang",
"dojo/date/locale",
"esri/dijit/Geocoder",
"esri/dijit/LocateButton",
"dojo/domReady!"
],
function (
esriConfig, InfoTemplate, Map, Popup, PopupTemplate, Extent, ArcGISDynamicMapServiceLayer, FeatureLayer,
ArcGISTiledMapServiceLayer, SimpleFillSymbol, SimpleLineSymbol,
GeometryService, Query, domConstruct, domClass, parser, Color, lang, locale, Geocoder, LocateButton
) {

parser.parse();


var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 0]), 2), new Color([128, 128, 128, 0.25]))
}, domConstruct.create("div"));

domClass.add(popup.domNode, "myTheme");

map = new Map("map", {
basemap: "topo",
center: [-122.402, 47],
zoom: 9,
infoWindow: popup
});

var geocoder = new Geocoder({
arcgisGeocoder: {
placeholder: "Search "
},
map: map
}, "ui-esri-dijit-geocoder");

var _countyCensusInfoTemplate = new InfoTemplate();
_countyCensusInfoTemplate.setTitle("<b>Census Information</b>");

var _blockGroupInfoTemplate = new InfoTemplate();
_blockGroupInfoTemplate.setTitle("<b>Census Information</b>");

var _censusInfoContent =
"<div class="demographicInfoContent">" +
"<div class='demographicNumericPadding'>${AGE_5_17:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 5 - 17<br>" +
"<div class='demographicNumericPadding'>${AGE_18_21:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 18 - 21<br>" +
"<div class='demographicNumericPadding'>${AGE_22_29:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 22 - 29<br>" +
"<div class='demographicNumericPadding'>${AGE_30_39:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 30 - 39<br>" +
"<div class='demographicNumericPadding'>${AGE_40_49:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 40 - 49<br>" +
"<div class='demographicNumericPadding'>${AGE_50_64:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 50 - 64<br>" +
"<div class='demographicNumericPadding'>${AGE_65_UP:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 65 and older" +
"</div>";

_countyCensusInfoTemplate.setContent("Demographics for:<br>${NAME} ${STATE_NAME:getCounty}, ${STATE_NAME}<br>" + _censusInfoContent);
_blockGroupInfoTemplate.setContent("Demographics for:<br>Tract: ${TRACT:formatNumber} Blockgroup: ${BLKGRP}<br>" + _censusInfoContent);

var demographicsLayerURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
var demographicsLayerOptions = {
"id": "demographicsLayer",
"opacity": 0.8,
"showAttribution": false
};

var demographicsLayer = new ArcGISDynamicMapServiceLayer(demographicsLayerURL, demographicsLayerOptions);
demographicsLayer.setInfoTemplates({
1: { infoTemplate: _blockGroupInfoTemplate },
2: { infoTemplate: _countyCensusInfoTemplate }
});
demographicsLayer.setVisibleLayers([1, 2]);
map.addLayer(demographicsLayer);

geocoder.startup();

var geoLocate = new LocateButton({
map: map,
highlightLocation: false
}, "LocateButton"
);
geoLocate.startup();

var formatNumber = function(value, key, data) {
var searchText = "" + value;
var formattedString = searchText.replace(/(d)(?=(ddd)+(?!d))/gm, "$1,");
return formattedString;
};

var getCounty = function(value, key, data) {
if (value.toUpperCase() !== "LOUISIANA") {
return "County";
} else {
return "Parish";
}
};

map.on("click", function (event) {
var query = new Query();
query.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = featureLayer.selectFeatures(query,
FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
});

var template = new InfoTemplate();
template.setTitle("Park Information");
template.setContent(getTextContent);

var featureLayer = new FeatureLayer("https://services3.arcgis.com/J1Locv0GPOt6yBRR/ArcGIS/rest/services/Parks_polygons_Feb2012/FeatureServer/0",
{
outFields: ["*"],
infoTemplate: template
});

map.addLayer(featureLayer);

function getTextContent (graphic) {
var attributes = graphic.attributes;
var namepark =
attributes.ParkName
.replace('"', "")
.split("::")
.map(function (name) {
return lang.trim(name);
});

var parkdata = namepark[0];
var commonName = namepark[1];
var parks;

if (commonName) {
parks = "<b>" + commonName + "</b><br/>" +
"<i>" + parkdata + "</i>";
}
else {
parks = "<i>" + parkdata + "</i>";
}

return parks + "<br>" +
attributes.Owner + "<br>" +
attributes.ParkWebLin
}

function pointToExtent (map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleranceInMapCoords = toleranceInPixel * pixelWidth;
return new Extent(point.x - toleranceInMapCoords,
point.y - toleranceInMapCoords,
point.x + toleranceInMapCoords,
point.y + toleranceInMapCoords,
map.spatialReference);
}

});
</script>
</head>

<body class="claro">
<div id="map">
<div id="LocateButton"></div>
</div>
<div id="ui-esri-dijit-geocoder"></div>

</body>


link to is http://students.washington.edu/sbuffor/combined_census_parks.html










share|improve this question
















Demographics data shows upon first click but not after, park information does work. I've changed around almost everything with non real solution. I feel like for whatever reason my feature server data is preferred over the dynamiclayer in the map. Is there a way to make the js bounce based on where you click?



    var map;

require([
"esri/config",
"esri/InfoTemplate",
"esri/map",
"esri/dijit/Popup",
"esri/dijit/PopupTemplate",
"esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/tasks/GeometryService",
"esri/tasks/query",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/parser",
"esri/Color",
"dojo/_base/lang",
"dojo/date/locale",
"esri/dijit/Geocoder",
"esri/dijit/LocateButton",
"dojo/domReady!"
],
function (
esriConfig, InfoTemplate, Map, Popup, PopupTemplate, Extent, ArcGISDynamicMapServiceLayer, FeatureLayer,
ArcGISTiledMapServiceLayer, SimpleFillSymbol, SimpleLineSymbol,
GeometryService, Query, domConstruct, domClass, parser, Color, lang, locale, Geocoder, LocateButton
) {

parser.parse();


var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 0, 0]), 2), new Color([128, 128, 128, 0.25]))
}, domConstruct.create("div"));

domClass.add(popup.domNode, "myTheme");

map = new Map("map", {
basemap: "topo",
center: [-122.402, 47],
zoom: 9,
infoWindow: popup
});

var geocoder = new Geocoder({
arcgisGeocoder: {
placeholder: "Search "
},
map: map
}, "ui-esri-dijit-geocoder");

var _countyCensusInfoTemplate = new InfoTemplate();
_countyCensusInfoTemplate.setTitle("<b>Census Information</b>");

var _blockGroupInfoTemplate = new InfoTemplate();
_blockGroupInfoTemplate.setTitle("<b>Census Information</b>");

var _censusInfoContent =
"<div class="demographicInfoContent">" +
"<div class='demographicNumericPadding'>${AGE_5_17:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 5 - 17<br>" +
"<div class='demographicNumericPadding'>${AGE_18_21:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 18 - 21<br>" +
"<div class='demographicNumericPadding'>${AGE_22_29:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 22 - 29<br>" +
"<div class='demographicNumericPadding'>${AGE_30_39:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 30 - 39<br>" +
"<div class='demographicNumericPadding'>${AGE_40_49:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 40 - 49<br>" +
"<div class='demographicNumericPadding'>${AGE_50_64:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 50 - 64<br>" +
"<div class='demographicNumericPadding'>${AGE_65_UP:formatNumber}</div><div class="demographicInnerSpacing"></div>people ages 65 and older" +
"</div>";

_countyCensusInfoTemplate.setContent("Demographics for:<br>${NAME} ${STATE_NAME:getCounty}, ${STATE_NAME}<br>" + _censusInfoContent);
_blockGroupInfoTemplate.setContent("Demographics for:<br>Tract: ${TRACT:formatNumber} Blockgroup: ${BLKGRP}<br>" + _censusInfoContent);

var demographicsLayerURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer";
var demographicsLayerOptions = {
"id": "demographicsLayer",
"opacity": 0.8,
"showAttribution": false
};

var demographicsLayer = new ArcGISDynamicMapServiceLayer(demographicsLayerURL, demographicsLayerOptions);
demographicsLayer.setInfoTemplates({
1: { infoTemplate: _blockGroupInfoTemplate },
2: { infoTemplate: _countyCensusInfoTemplate }
});
demographicsLayer.setVisibleLayers([1, 2]);
map.addLayer(demographicsLayer);

geocoder.startup();

var geoLocate = new LocateButton({
map: map,
highlightLocation: false
}, "LocateButton"
);
geoLocate.startup();

var formatNumber = function(value, key, data) {
var searchText = "" + value;
var formattedString = searchText.replace(/(d)(?=(ddd)+(?!d))/gm, "$1,");
return formattedString;
};

var getCounty = function(value, key, data) {
if (value.toUpperCase() !== "LOUISIANA") {
return "County";
} else {
return "Parish";
}
};

map.on("click", function (event) {
var query = new Query();
query.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = featureLayer.selectFeatures(query,
FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
});

var template = new InfoTemplate();
template.setTitle("Park Information");
template.setContent(getTextContent);

var featureLayer = new FeatureLayer("https://services3.arcgis.com/J1Locv0GPOt6yBRR/ArcGIS/rest/services/Parks_polygons_Feb2012/FeatureServer/0",
{
outFields: ["*"],
infoTemplate: template
});

map.addLayer(featureLayer);

function getTextContent (graphic) {
var attributes = graphic.attributes;
var namepark =
attributes.ParkName
.replace('"', "")
.split("::")
.map(function (name) {
return lang.trim(name);
});

var parkdata = namepark[0];
var commonName = namepark[1];
var parks;

if (commonName) {
parks = "<b>" + commonName + "</b><br/>" +
"<i>" + parkdata + "</i>";
}
else {
parks = "<i>" + parkdata + "</i>";
}

return parks + "<br>" +
attributes.Owner + "<br>" +
attributes.ParkWebLin
}

function pointToExtent (map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleranceInMapCoords = toleranceInPixel * pixelWidth;
return new Extent(point.x - toleranceInMapCoords,
point.y - toleranceInMapCoords,
point.x + toleranceInMapCoords,
point.y + toleranceInMapCoords,
map.spatialReference);
}

});
</script>
</head>

<body class="claro">
<div id="map">
<div id="LocateButton"></div>
</div>
<div id="ui-esri-dijit-geocoder"></div>

</body>


link to is http://students.washington.edu/sbuffor/combined_census_parks.html







arcgis-javascript-api dojo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 12 '15 at 3:50









PolyGeo

54.1k1782246




54.1k1782246










asked Dec 9 '15 at 3:31









StaleyStaley

144111




144111













  • Cross-posted from stackoverflow.com/questions/34120616/…

    – PolyGeo
    Dec 8 '15 at 0:06






  • 1





    Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

    – PolyGeo
    Dec 8 '15 at 0:10











  • 2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

    – Tom
    Dec 8 '15 at 15:52











  • Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

    – Staley
    Dec 8 '15 at 17:44











  • This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

    – Staley
    Dec 8 '15 at 19:09



















  • Cross-posted from stackoverflow.com/questions/34120616/…

    – PolyGeo
    Dec 8 '15 at 0:06






  • 1





    Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

    – PolyGeo
    Dec 8 '15 at 0:10











  • 2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

    – Tom
    Dec 8 '15 at 15:52











  • Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

    – Staley
    Dec 8 '15 at 17:44











  • This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

    – Staley
    Dec 8 '15 at 19:09

















Cross-posted from stackoverflow.com/questions/34120616/…

– PolyGeo
Dec 8 '15 at 0:06





Cross-posted from stackoverflow.com/questions/34120616/…

– PolyGeo
Dec 8 '15 at 0:06




1




1





Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

– PolyGeo
Dec 8 '15 at 0:10





Welcome to GIS SE! As a new user be sure to take the Tour. For some ideas on how to structure a question to attract potential answerers I recommend reviewing meta.gis.stackexchange.com/a/3353/115

– PolyGeo
Dec 8 '15 at 0:10













2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

– Tom
Dec 8 '15 at 15:52





2. Using htmlPrettify you will see that your code isn't able to format properly, that's how I found the extra closures in there. 3. Yes name the popups differently, but you cannot change the class name! ie "var popup1 = new Popup()" - where Popup() is the class name. You can differentiate the variable name (you must in fact) ie "var parkPopup" vs "var blockPopup" but you must leave " = new Popup()" as is - that is the class.

– Tom
Dec 8 '15 at 15:52













Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

– Staley
Dec 8 '15 at 17:44





Ok the map is rendering but the demographics info only comes up on the first click. I assume this relates to your comment "Make the div first with dojo attach point?" but I'm not sure what you mean.

– Staley
Dec 8 '15 at 17:44













This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

– Staley
Dec 8 '15 at 19:09





This is my latest point of hangup...students.washington.edu/sbuffor/combined_census_parks.html I can't get the demographics info to show after the first click, if you click the parks first demographics doesn't come up at all.

– Staley
Dec 8 '15 at 19:09










1 Answer
1






active

oldest

votes


















2














I started removing pieces and found a piece that I didn't completely understand what it was doing and pulled it out.



map.on("click", function (event) {
var query = new Query();
query.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = featureLayer.selectFeatures(query,
FeatureLayer.SELECTION_NEW);
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
});


Upon doing this the map now is completely operational!



Also I took the advice to add the URL to the park info, got that added in as well, although I did remove the "getTextContent" piece out of it to get it to render properly but it works quite well. I also added another piece to open the link in a new tab.






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f173157%2fesri-api-js-popup-not-displaying-after-first-click%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I started removing pieces and found a piece that I didn't completely understand what it was doing and pulled it out.



    map.on("click", function (event) {
    var query = new Query();
    query.geometry = pointToExtent(map, event.mapPoint, 10);
    var deferred = featureLayer.selectFeatures(query,
    FeatureLayer.SELECTION_NEW);
    map.infoWindow.setFeatures([deferred]);
    map.infoWindow.show(event.mapPoint);
    });


    Upon doing this the map now is completely operational!



    Also I took the advice to add the URL to the park info, got that added in as well, although I did remove the "getTextContent" piece out of it to get it to render properly but it works quite well. I also added another piece to open the link in a new tab.






    share|improve this answer






























      2














      I started removing pieces and found a piece that I didn't completely understand what it was doing and pulled it out.



      map.on("click", function (event) {
      var query = new Query();
      query.geometry = pointToExtent(map, event.mapPoint, 10);
      var deferred = featureLayer.selectFeatures(query,
      FeatureLayer.SELECTION_NEW);
      map.infoWindow.setFeatures([deferred]);
      map.infoWindow.show(event.mapPoint);
      });


      Upon doing this the map now is completely operational!



      Also I took the advice to add the URL to the park info, got that added in as well, although I did remove the "getTextContent" piece out of it to get it to render properly but it works quite well. I also added another piece to open the link in a new tab.






      share|improve this answer




























        2












        2








        2







        I started removing pieces and found a piece that I didn't completely understand what it was doing and pulled it out.



        map.on("click", function (event) {
        var query = new Query();
        query.geometry = pointToExtent(map, event.mapPoint, 10);
        var deferred = featureLayer.selectFeatures(query,
        FeatureLayer.SELECTION_NEW);
        map.infoWindow.setFeatures([deferred]);
        map.infoWindow.show(event.mapPoint);
        });


        Upon doing this the map now is completely operational!



        Also I took the advice to add the URL to the park info, got that added in as well, although I did remove the "getTextContent" piece out of it to get it to render properly but it works quite well. I also added another piece to open the link in a new tab.






        share|improve this answer















        I started removing pieces and found a piece that I didn't completely understand what it was doing and pulled it out.



        map.on("click", function (event) {
        var query = new Query();
        query.geometry = pointToExtent(map, event.mapPoint, 10);
        var deferred = featureLayer.selectFeatures(query,
        FeatureLayer.SELECTION_NEW);
        map.infoWindow.setFeatures([deferred]);
        map.infoWindow.show(event.mapPoint);
        });


        Upon doing this the map now is completely operational!



        Also I took the advice to add the URL to the park info, got that added in as well, although I did remove the "getTextContent" piece out of it to get it to render properly but it works quite well. I also added another piece to open the link in a new tab.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 6 '16 at 23:49









        PolyGeo

        54.1k1782246




        54.1k1782246










        answered Dec 10 '15 at 4:08









        StaleyStaley

        144111




        144111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f173157%2fesri-api-js-popup-not-displaying-after-first-click%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

            Meter-Bus Содержание Параметры шины | Стандартизация |...