|
POST
|
Hi All, Struggling trying to parse selected attribute to a table DIV . Tried to create tabledivas seen below. Sample code is from this link https://developers.arcgis.com/javascript/latest/sample-code/popup-custom-action/index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"> <title>Custom popup actions per feature attribute - 4.4</title> <style> body { font-family: sans-serif; padding: 0; margin: 0; height: 100%; width: 100%; overflow: hidden; } #viewDiv { position: absolute; right: 0; left: 0; top: 0; bottom: 0; } </style> <link rel="stylesheet" href="https://js.arcgis.com/4.4/esri/css/main.css"> <script src="https://js.arcgis.com/4.4/"></script> <script> require([ "esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer", "dojo/domReady!" ], function( Map, MapView, FeatureLayer ) { var map = new Map({ basemap: "streets-navigation-vector" }); var view = new MapView({ container: "viewDiv", map: map, center: [0.46564130, 51.736810] , zoom: 17 }); /******************** * Add feature layer ********************/ // sampling of breweries var featureLayer = new FeatureLayer({ url: "https://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/AddressA_csv/FeatureServer/0", outFields: ["*"], //definitionExpression: "country = 'United States'", // add a custom action popupTemplate: { title: "{Postcode}", content: [{ type: "fields", fieldInfos: [{ fieldName: "Postcode" }] }], actions: [{ id: "find-brewery", image: "beer.png", title: "Brewery Info" }] } }); map.add(featureLayer); function showResults(response) { var tbl = document.getElementById("tableDiv"); var tblBody = document.createElement("tbody"); var header = tbl.createTHead(); var headerRow = header.insertRow(0); var headerCell = document.createElement("th"); headerCell.innerHTML = "Name"; headerRow.appendChild(headerCell); var headerCell2 = document.createElement("th"); headerCell2.innerHTML = "Alias"; headerRow.appendChild(headerCell2); var attributes = popup.viewModel.selectedFeature.attributes; // Get the "website" field attribute var info = attributes.Postcode; info.parse(response).fields.forEach(function(field){ var row = document.createElement("tr"); var cell = document.createElement("td"); var cell2 = document.createElement("td"); cell.innerHTML = field.name; cell2.innerHTML = field.alias; row.appendChild(cell); row.appendChild(cell2); tblBody.appendChild(row); }); tbl.appendChild(tblBody); } } console.info(response); }; view.then(function() { var popup = view.popup; popup.viewModel.on("trigger-action", function(event) { if (event.action.id === "find-brewery") { var attributes = popup.viewModel.selectedFeature.attributes; // Get the "website" field attribute var info = attributes.Postcode; // Make sure the "website" attribute value is not null if (info !== null) { // Open up a new browser using the URL value in the 'website' field // window.open(info.trim()); showResults(info.trim()); // If the "website" value is null, open a new window and Google search the name of the brewery } //else { //window.open("https://www.google.com/search?q=" + // attributes.Postcode); // } } }); }); }); </script> </head> <body class="light"> <div id="viewDiv" style="float: left; width: 80%; height: 95%;"> <table id="tbl" style="float: right; width: 10%; height: 16%;">></table> <table id="tableDiv" style="float: right; width: 200%; height: 20%;">></table> </div> </body> </html>
... View more
08-14-2017
02:21 PM
|
0
|
2
|
1035
|
|
POST
|
how do will the text string be played as a html or table div
... View more
08-14-2017
12:26 PM
|
0
|
3
|
1677
|
|
POST
|
I want to be able to see this text string in a table next to the mapview, how do I do this. I thought the tablediv will be useful
... View more
08-14-2017
12:12 PM
|
0
|
0
|
1677
|
|
POST
|
Thanks Robert Scheitlin. Will the console get the attribution as html table or a text string?
... View more
08-14-2017
09:21 AM
|
0
|
6
|
1677
|
|
POST
|
Hi All Got the sample code from the link below https://developers.arcgis.com/javascript/latest/sample-code/popup-custom-action/index.html I have modified the attribute table to fit to my attribute table. so from the sample if you click on the bewrey info, instead of linking to a website. I want to Location attribute to be return as a table or json. see the code below. I have set var info to get the LOCATION. How do I parse it so it shows as as a json format or table? <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no"> <title>Custom popup actions per feature attribute - 4.4</title> <style> body { font-family: sans-serif; padding: 0; margin: 0; height: 100%; width: 100%; overflow: hidden; } #viewDiv { position: absolute; right: 0; left: 0; top: 0; bottom: 0; } </style> <link rel="stylesheet" href="https://js.arcgis.com/4.4/esri/css/main.css"> <script src="https://js.arcgis.com/4.4/"></script> <script> require([ "esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer", "dojo/domReady!" ], function( Map, MapView, FeatureLayer ) { var map = new Map({ basemap: "streets-navigation-vector" }); var view = new MapView({ container: "viewDiv", map: map, center: [0.46564130, 51.736810] , zoom: 17 }); /******************** * Add feature layer ********************/ // sampling of breweries var featureLayer = new FeatureLayer({ url: " https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/Esri_carparks/FeatureServer/0", outFields: ["*"], // definitionExpression: "country = 'United States'", // add a custom action popupTemplate: { title: "{name}", content: [{ type: "fields", fieldInfos: [{ fieldName: "LOCATION" }, { fieldName: "address1", label: "address" }, { fieldName: "city" }, { fieldName: "state" }, { fieldName: "phone" }, { fieldName: "website" }] }], actions: [{ id: "find-ADDRESS", image: "beer.png", title: "Brewery Info" }] } }); map.add(featureLayer); var resultsTable = dom.byId("tbl"); function showResults(response) { var results = response.results; // Clear the cells and rows of the table to make room for new results resultsTable.innerHTML = ""; if (results.length === 0) { resultsTable.innerHTML = "<i>No results found</i>"; loadingImg.style.visibility = "hidden"; return; } } view.then(function() { var popup = view.popup; popup.viewModel.on("trigger-action", function(event) { if (event.action.id === "find-ADDRESS") { var attributes = popup.viewModel.selectedFeature.attributes; // Get the "website" field attribute var info = attributes.LOCATION; // Make sure the "website" attribute value is not null if (info !== null) { // Open up a new browser using the URL value in the 'website' field //CELL.open(info.trim()); showResults(); // If the "website" value is null, open a new window and Google search the name of the brewery } } }); }); }); </script> </head> <body class="light"> <div id="viewDiv"> </div> </body> </html>
... View more
08-13-2017
04:46 PM
|
0
|
8
|
2349
|
|
POST
|
ok, see below <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title>DevLabs - Search and Geocode</title> <style> html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; } </style> <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css"> <script src="https://js.arcgis.com/4.3/"></script> <script> require([ "esri/Map", "esri/views/MapView", "esri/widgets/Search", "esri/layers/FeatureLayer", "dojo/domReady!" ], function(Map, MapView, Search, FeatureLayer) { var map = new Map({ basemap: "streets-vector" }); // Add the layer to the map var trailsLayer = new FeatureLayer({ url: "https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/Export_Output/FeatureServer/0", }); //map.add(trailsLayer); // Optionally add layer to map // Add the layer to the map var trailsLayer2 = new FeatureLayer({ url: "https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/Export_Output/FeatureServer/0", }); map.add(trailsLayer2); // Optionally add layer to map // Add the layer to the map var trailsLayer3 = new FeatureLayer({ url: "https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/wards_crm/FeatureServer/0", }); map.add(trailsLayer3); // Optionally add layer to map var view = new MapView({ container: "viewDiv", map: map, zoom: 19, center: [0.46564130, 51.736810] // longitude, latitude }); // Search var search = new Search({ view: view }); search.defaultSource.withinViewEnabled = false; // Limit search to visible map area only view.ui.add(search, "top-right"); // Add to the map // Add the trailheads as a search source search.sources.push({ featureLayer: trailsLayer, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "Postcode", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Postcode", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); search.sources.push({ featureLayer: trailsLayer2, searchFields: [ "UPRN", "ADDRESS" ], displayField: "ADDRESS", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Inborough Addresses", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); search.sources.push({ featureLayer: trailsLayer3, searchFields: ["WARD_N" ], displayField: "WARD_N", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Wards", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); function searchcomplete( search-complete) { view.popup.open({ activeSourceIndex: Number, errors: Error[], numResults: Number, searchTerm: String, results: Object[], }); }, searchWidget.on("search-complete", searchcomplete); });</script> </head> <body> <div id="viewDiv"></div> </body> </html>
... View more
08-10-2017
08:00 AM
|
0
|
1
|
1071
|
|
POST
|
ok have made the changes does this seem right searchWidget.on("search-complete", function(searchcomplete){ // The results are stored in the event Object[] console.log("Results of the search: ", searchcomplete); });
... View more
08-10-2017
07:02 AM
|
0
|
3
|
1071
|
|
POST
|
Hi Again, My searchwidget is working alright, it displays the search with a popup template. The problem now is to get the result of the search as a json object or a table. I have search the api references, and its the search-complete that returns search as an object. my code isn't right. Any help please see below, // Search var search = new Search({ view: view }); search.defaultSource.withinViewEnabled = true; // Limit search to visible map area only view.ui.add(search, "top-right"); // Add to the map // Add the trailheads as a search source search.sources.push({ featureLayer: trailsLayer, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "Postcode", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Postcode", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); search.sources.push({ featureLayer: trailsLayerr, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "Postcode", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Postcode", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); function searchcomplete( search-complete) { view.popup.open({ activeSourceIndex: Number, errors: Error[], numResults: Number, searchTerm: String, results: Object[], } }); searchWidget.on("search-complete", function(event){ // The results are stored in the event Object[] console.log("Results of the search: ", event); }); }); });</script> </head> <body> <div id="viewDiv"></div>
... View more
08-10-2017
02:05 AM
|
0
|
5
|
1428
|
|
POST
|
Hi All, my search widget uses both geocoding service and two feature sources. However, I m having trouble having , it highlights the ESRI geocoder as the first source of search instead of ALL. How do I make the ALL the default search so it searches all sources. Thanks in advance // Add the layer to the map var trailsLayer = new FeatureLayer({ url: "https://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/myApp/FeatureServer/0", }); map.add(trailsLayer); // Optionally add layer to map // Add the layer to the map var trailsLayerr = new FeatureLayer({ url: "https://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/AddressA_csv/FeatureServer/0", }); map.add(trailsLayerr); // Optionally add layer to map var view = new MapView({ container: "viewDiv", map: map, zoom: 17, center: [0.46564130, 51.736810] // longitude, latitude }); // Search var search = new Search({ view: view }); search.defaultSource.withinViewEnabled = true; // Limit search to visible map area only view.ui.add(search, "top-right"); // Add to the map // Add the trailheads as a search source search.sources.push({ featureLayer: trailsLayer, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "ADDRESS", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "ADDRESS", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); search.sources.push({ featureLayer: trailsLayerr, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "ADDRESS", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Postcode", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); });</script> </head> <body> <div id="viewDiv"></div> </body>
... View more
08-06-2017
01:07 PM
|
0
|
2
|
1530
|
|
POST
|
Hi All, I need help again please. I have a geocoding service which when you search address in the search widget. It returns approximate xy coordinates. I have a feature layer also as one of the sources in my search widget if a user types in an address in the search box and the result of the search is from the geocoding service, I want the code to identity the result as it works now see below code. I also want the code to get the nearest feature layer source which are added as points in the code. Any help on how to get the nearest feature source layer? Thanks in advance <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title>DevLabs - Search and Geocode</title> <style> html, body, #viewDiv { padding: 0; margin: 0; height: 100%; width: 100%; } </style> <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css"> <script src="https://js.arcgis.com/4.3/"></script> <script> require([ "esri/Map", "esri/views/MapView", "esri/widgets/Search", "esri/layers/FeatureLayer", "dojo/domReady!" ], function(Map, MapView, Search, FeatureLayer) { var map = new Map({ basemap: "streets-vector" }); // Add the layer to the map var trailsLayer = new FeatureLayer({ url: "https://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/myApp/FeatureServer/0", }); map.add(trailsLayer); // Optionally add layer to map // Add the layer to the map var trailsLayerr = new FeatureLayer({ url: "https://services7.arcgis.com/uE69mPI6U3rpSmCT/arcgis/rest/services/AddressA_csv/FeatureServer/0", }); map.add(trailsLayerr); // Optionally add layer to map var view = new MapView({ container: "viewDiv", map: map, zoom: 17, center: [0.46564130, 51.736810] // longitude, latitude }); // Search var search = new Search({ view: view }); search.defaultSource.withinViewEnabled = true; // Limit search to visible map area only view.ui.add(search, "top-right"); // Add to the map // Add the trailheads as a search source search.sources.push({ featureLayer: trailsLayer, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "ADDRESS", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "ADDRESS", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); search.sources.push({ featureLayer: trailsLayerr, searchFields: ["Postcode", "UPRN", "ADDRESS" ], displayField: "ADDRESS", exactMatch: false, outFields: ["*"], resultGraphicEnabled: true, name: "Postcode", placeholder: "example: CM2 0HU", popupTemplate: { // autocasts as new popupTemplate() title: "Post Code: {Postcode}</br>UPRN: {UPRN}</br>ADDRESS: {ADDRESS}", overwriteActions: true } }); // Find address function showPopup(address, pt) { view.popup.open({ title: "Find Address Result", content: address + "<br><br> Lat: " + Math.round(pt.latitude * 100000)/100000 + " Lon: " + Math.round(pt.longitude * 100000)/100000, location: pt }); } view.on("click", function(evt){ search.clear(); view.popup.clear(); var locatorSource = search.defaultSource; locatorSource.locator.locationToAddress(evt.mapPoint) .then(function(response) { var address = response.address.Match_addr; // Show the address found showPopup(address, evt.mapPoint); }, function(err) { // Show no address found showPopup("No address found for this location.", evt.mapPoint); }); }); });</script> </head> <body> <div id="viewDiv"></div> </body> </html> .
... View more
07-31-2017
03:58 PM
|
0
|
0
|
830
|
|
POST
|
Hi All, Finally resolved the issue. Did save as numbers in excel and then resave as a string in ArcGIS Online. The numbers are exactly the same as it is on the spreadsheet.
... View more
07-28-2017
06:25 AM
|
0
|
0
|
886
|
|
POST
|
hi steve, I have changed the format to TEXT. this is what I get 100090429674 changes to 100090000000
... View more
07-27-2017
01:25 PM
|
0
|
1
|
886
|
|
POST
|
Hi All, I have spent a lot of time trying to figure this out in excel. The issue is my Number column in excel displays scientific number; 1.00091E+11 1.00091E+11 I have used the format cells to numbers but when I save and reopens the scientific numbers comes back. This is an issue when using the csv as a search layer. It gives random numbers. I want the unique numbers to be displayed as it is.. 100090429674 100090429671 100091440630 200004639203. this is my code; // Add the layer to the map var trailsLayer2 = new FeatureLayer({ url: "https://services1.arcgis.com/BZNs0xaSHDSi4V6G/arcgis/rest/services/Addresses_A/FeatureServer/0", }); map.add(trailsLayer2); // Optionally add layer to map At the moment my info table displays 100090429671 as 1000000000000.
... View more
07-27-2017
07:49 AM
|
0
|
3
|
1061
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-21-2017 05:23 AM | |
| 1 | 11-15-2017 09:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|