Click here to Skip to main content
15,885,985 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionIssue With JavaScript and ClearScript Pin
Alan Burkhart13-Jul-18 13:10
Alan Burkhart13-Jul-18 13:10 
AnswerRe: Issue With JavaScript and ClearScript Pin
Graham Breach14-Jul-18 2:07
Graham Breach14-Jul-18 2:07 
GeneralRe: Issue With JavaScript and ClearScript Pin
Alan Burkhart14-Jul-18 3:49
Alan Burkhart14-Jul-18 3:49 
QuestionJavaScript Pin
Member 99702028-Jul-18 20:15
Member 99702028-Jul-18 20:15 
AnswerRe: JavaScript Pin
Member 997020210-Jul-18 4:44
Member 997020210-Jul-18 4:44 
QuestionNeed some help with app, please. Pin
Member 1388357522-Jun-18 12:03
Member 1388357522-Jun-18 12:03 
AnswerRe: Need some help with app, please. Pin
Nathan Minier25-Jun-18 1:49
professionalNathan Minier25-Jun-18 1:49 
QuestionCreating hexbins visualisation with mapbox in an angular 4 project Pin
Member 1387271014-Jun-18 2:35
Member 1387271014-Jun-18 2:35 
I'm getting started with web development, I try to create a hexbins visualisation with mapbox in an angular 4 project but I'm getting an error:
Quote:
core.js:1448 ERROR Error: Uncaught (in promise): Error: options is invalid
Error: options is invalid
at Object.Oo [as hexGrid] (turf.min.js:1)
at eval (map.component.ts:443)

Here is my code:
d3.json<ResponseData>('http://127.0.0.1:5000')
        .then((data) => {

          console.log('hex load!');

          // filter out data with no geometry, otherwise MapboxGL throws an error and won't load data
          data.features = data.features.filter(function (d) {
            return d.geometry;
          });
          console.log('hex 1');

          // bounding box for our data's extent (I computed this ahead of time)
          var bbox = [14.334434, 46.6841, 16.552692, 48.5308];
          // our cell size, try changing this to a different value like 10
          var cellSize = 1;
          // units of our cells
          var units = 'kilometers';
          console.log('hex 2');
          console.log(data);

          // create our hex grid
          var hexgrid = turf.hexGrid(bbox, cellSize, units);

          //expcount the number of crashes in each hex grid, this will take a few seconds.
          // in an real life app we would want to display a loading GIF or message here
          console.log('binning data, hold on tight...');
          var hexPoints = turf.count(hexgrid, data, 'totalPoints');
          console.log('done! ', hexPoints);

          // create a jenks natural breaks classification, see: https://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization
          // the number of breaks we are using
          var numberBreaks = 5;

          // NOTE: turf-jenks is technically depreciated, but it still works
          var jenksBreaks = turf.jenks(hexPoints, 'totalPoints', numberBreaks);
          console.log('our jenksBreaks array: ', jenksBreaks);

          // via color brewer: http://colorbrewer2.org/#type=sequential&scheme=RdPu&n=5
          var colors = ['#3bb3c3', '#669ec4', '#8b88b6', '#7a0177', '#aa5e79'];

          // create our color stops for the hexCrashes map layer style
          var colorStops = jenksBreaks.map(function (b, i) {
            if (i > 0) {
              // here we map each color in the color array to it's corresponding bin
              return [b, colors[i - 1]];
            } else {
              // in the case of 0, hide the bin
              return [b, 'rgba(255, 255, 255, 0)'];
            }
          });

          // add our hex crashes layer data
          map.addSource('pointsHexGrid', {
            type: 'geojson',
            data: hexPoints
          });

          // add our hex crashes layer style
          map.addLayer({
            "id": "pointsHexGrid",
            "type": "fill",
            "source": "pointsHexGrid",
            "layout": {},
            "paint": {
              'fill-color': {
                property: 'totalPoints',
                stops: colorStops,
              },
              'fill-opacity': 0.6
            }
          });

        })
        .catch((err) => {
          if (err) throw err;
        });

Please can someone guide me to the source of this error? (In a simple HTML file the visualisation works fine and shows my data correctly)
QuestionJavascript function - onclick problem Pin
Member 201089711-Jun-18 16:23
Member 201089711-Jun-18 16:23 
AnswerRe: Javascript function - onclick problem Pin
Member 1387615717-Jun-18 19:57
Member 1387615717-Jun-18 19:57 
GeneralRe: Javascript function - onclick problem Pin
Richard MacCutchan17-Jun-18 21:49
mveRichard MacCutchan17-Jun-18 21:49 
Questionnot work onClick operation Pin
Member 1382834015-May-18 6:29
Member 1382834015-May-18 6:29 
SuggestionRe: not work onClick operation Pin
Richard Deeming15-May-18 9:10
mveRichard Deeming15-May-18 9:10 
GeneralRe: not work onClick operation Pin
Shivnandan singh25-May-18 0:31
Shivnandan singh25-May-18 0:31 
AnswerRe: not work onClick operation Pin
Shivnandan singh25-May-18 0:32
Shivnandan singh25-May-18 0:32 
GeneralCall jquery function after partial view page return. Pin
Rahulgupta.hanu14-May-18 3:28
Rahulgupta.hanu14-May-18 3:28 
GeneralRe: Call jquery function after partial view page return. Pin
CP_Member88829-Jul-18 19:32
CP_Member88829-Jul-18 19:32 
QuestionJava script and SQL Pin
Johannes Moolman7-May-18 23:04
Johannes Moolman7-May-18 23:04 
AnswerRe: Java script and SQL Pin
W Balboos, GHB9-May-18 8:54
W Balboos, GHB9-May-18 8:54 
QuestionMVVM knockoutjs Grid Pin
padav146-May-18 0:01
padav146-May-18 0:01 
AnswerRe: MVVM knockoutjs Grid Pin
Afzaal Ahmad Zeeshan6-May-18 3:04
professionalAfzaal Ahmad Zeeshan6-May-18 3:04 
QuestionBeginner, no pc Pin
Rufus1827-Apr-18 0:29
Rufus1827-Apr-18 0:29 
AnswerRe: Beginner, no pc Pin
F-ES Sitecore27-Apr-18 1:54
professionalF-ES Sitecore27-Apr-18 1:54 
GeneralRe: Beginner, no pc Pin
Anushkasharma1021-Jun-18 3:42
Anushkasharma1021-Jun-18 3:42 
AnswerRe: Beginner, no pc Pin
Richard MacCutchan27-Apr-18 2:12
mveRichard MacCutchan27-Apr-18 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.