none
Display Pushpins using GeoJson.read RRS feed

  • Question

  • 

    I tried the following script and it generates the error: Unable to get property

    'draggable' of undefined or null reference. The map displays without the Point var map = null; function GetMap() { map = new Microsoft.Maps.Map('#myMap', { credentials: BingMapsKey, center: new Microsoft.Maps.Location(35.27, -80.00), zoom: 10 }); var myGeoJson = { "type": "FeatureCollection", "features": [ { "type": "Feature", "id": "pt01", "geometry": { "type": "Point", "coordinates": [-80.00286608398164, 35.27801752339406]} }]}; Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () { var shape = Microsoft.Maps.GeoJson.read(myGeoJson); map.entities.push(shape); }); }


    Tuesday, November 22, 2016 3:33 PM

Answers

  • I just realized that I was just missing a Title.  As soon as I add a Title it works!
    • Marked as answer by pjra3 Tuesday, November 22, 2016 5:02 PM
    Tuesday, November 22, 2016 5:01 PM
  • I took a look in this and found the issue. It appears that the code is looking for a properties value on the GeoJSON object. The GeoJSON module looks for certain properties and uses them to customize the shape. If there was a draggable property in the GeoJSON properties, then the pushpin would be draggable. However, since there is no properties value on the GeoJSON object, it is looking for a draggable property on an undefined value. I'll log a bug to have this fixed.

    You can work around this by adding the a properties property to your GeoJSON object like this:

        var myGeoJson = {
            "type": "FeatureCollection",
            "features": [
              {
                  "type": "Feature",
                  "id": "pt01",
    			  "properties": {},
                  "geometry": {
                      "type": "Point",
                      "coordinates": [-80.00286608398164, 35.27801752339406]}
              }]};


    [Blog] [twitter] [LinkedIn]

    Tuesday, November 22, 2016 5:43 PM
  • Good news, this has been resolved in the experimental branch. This fix will be added to the main release branch at the end of March.

    [Blog] [twitter] [LinkedIn]

    Friday, February 24, 2017 4:24 PM

All replies

  • I just realized that I was just missing a Title.  As soon as I add a Title it works!
    • Marked as answer by pjra3 Tuesday, November 22, 2016 5:02 PM
    Tuesday, November 22, 2016 5:01 PM
  • I took a look in this and found the issue. It appears that the code is looking for a properties value on the GeoJSON object. The GeoJSON module looks for certain properties and uses them to customize the shape. If there was a draggable property in the GeoJSON properties, then the pushpin would be draggable. However, since there is no properties value on the GeoJSON object, it is looking for a draggable property on an undefined value. I'll log a bug to have this fixed.

    You can work around this by adding the a properties property to your GeoJSON object like this:

        var myGeoJson = {
            "type": "FeatureCollection",
            "features": [
              {
                  "type": "Feature",
                  "id": "pt01",
    			  "properties": {},
                  "geometry": {
                      "type": "Point",
                      "coordinates": [-80.00286608398164, 35.27801752339406]}
              }]};


    [Blog] [twitter] [LinkedIn]

    Tuesday, November 22, 2016 5:43 PM
  • Good news, this has been resolved in the experimental branch. This fix will be added to the main release branch at the end of March.

    [Blog] [twitter] [LinkedIn]

    Friday, February 24, 2017 4:24 PM