none
Accessing URL with Microsoft..Maps.GeoJSON.readFromUrl RRS feed

  • Question

  • I am attempting the following code in JavaScript and not getting anything returned.

                myMap = map;
                Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
                    Microsoft.Maps.GeoJson.readFromUrl('https://api.weather.gov/alerts/active?event=Flood Warning&format=geojson', function (shapes) {
                        map.entities.push(shapes);
                    }, 'callback');

    Access to this URL works fine in the WPF Bing Maps. Do I need to do something special with the space after "Flood" in JavaScript?

    Thanks in advance - Dan

    Saturday, July 29, 2017 4:57 PM

Answers

  • The 'callback' value is only specified if the service you are using requires JSONP and the parameter it uses in the URL for callbacks is 'callback'. If it is a different url parameter, then change the value. If the service supports CORs, then remove this. I suspect that for this API you need to remove this from your code.

    That said, trying the URL you provided in a browser returns an empty response. I think there is an issue with this URL. Take a look at the documentation for the API you are using and verify that you can get this URL to return data through a browser first.


    [Blog] [twitter] [LinkedIn]

    Monday, July 31, 2017 1:07 PM