none
GeoJson unhandled exception RRS feed

  • Question

  • Hi,

    Got a GeoJson file which I have put through an online validator and says it's fine.  Have even tried it on the drag and drop example at https://bingmapsv8samples.azurewebsites.net/ and it loads it fine but when I try and use the code below (which loads another file I have fine) I get an unhandled exception.  Any ideas why ? 

    For info the error is along the lines of "Uncaught Network error occured while getting geoJson data from" - which I don't understand as the other file loads from same location.

     Microsoft.Maps.GeoJson.readFromUrl('../Content/Data/newPipes.json', function (featureCollection) { dataLayer.add(featureCollection); }, null);

    The file is very large but formatted thus:

    "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "geometry": {
            "type": "LineString",
            "coordinates": [
              [
                4.82659386436796,
                6.0109005308675805
              ],
              [
                4.870474585033455,
                5.960783742313984
              ],
              [
                4.897447259142002,
                5.945734418301204
              ],
              [
                4.837362025709645,
                5.895834667462559
              ],
              [
                4.772839929627048,
                5.813133516867436
              ]
            ]
          },
          "properties": {
            "type": "pipeline",
            "style": "fill:none;stroke:#554b44;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:0, 2;stroke-dashoffset:0"
          }
        },


    Matt J


    • Edited by Matt CJ Tuesday, December 12, 2017 3:19 PM
    Tuesday, December 12, 2017 2:15 PM

Answers

  • The error likely means that is an issue accessing your file. Try using an absolute URL to the file to see if that helps. Also, it is possible that your server may be blocking files that have .json extensions (fairly common) and you have to add the MIME type to your server settings. Be sure to also try accessing the file directly in a browser to see if it works. 

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Tuesday, December 12, 2017 5:58 PM
    • Marked as answer by Matt CJ Wednesday, December 13, 2017 10:17 AM
    Tuesday, December 12, 2017 5:58 PM

All replies

  • The error likely means that is an issue accessing your file. Try using an absolute URL to the file to see if that helps. Also, it is possible that your server may be blocking files that have .json extensions (fairly common) and you have to add the MIME type to your server settings. Be sure to also try accessing the file directly in a browser to see if it works. 

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Tuesday, December 12, 2017 5:58 PM
    • Marked as answer by Matt CJ Wednesday, December 13, 2017 10:17 AM
    Tuesday, December 12, 2017 5:58 PM
  • Thank's - kind of right :-) I had previously added .json files ... what I hadn't added was .GeoJson files which was what the extension of the new file was ... 

    Matt J

    Wednesday, December 13, 2017 10:19 AM