none
Not return all boundaries on census RRS feed

  • Question

  • Hi,

    We have used the code available at following  link https://www.bing.com/api/maps/sdk/mapcontrol/isdk#sdsChoroplethMap+JS and we used below query URL to read US postalzodes but it did not return all shapes some postal codes are missing.

    https://spatial.virtualearth.net/REST/v1/data/f42cab32d0ee41738d90856badd638d3/USCensus2010_ZCTA5/ZCTA5

    Is anyone have solution for this issue.

    Thanks!



    Balasaheb

    Sunday, September 13, 2020 6:02 PM

All replies

  • Hi Balasheb,

    Please provide the codes you are having issues with.  More likely your solution is not handling multipolygon postal regions as some codes return more than one polygon. Or the zipcode you are looking for may have changed since 2010.

    Sincerely,

    IoTGirl

    Monday, September 14, 2020 4:30 PM
    Owner
  • Hi,

    Below is the code.

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script type="text/javascript">
            var Maplytics_jQ = jQuery.noConflict();
        </script>
        <script type='text/javascript'>
            var map;       
            var counter = 0;
            var totalCensusQuery = 0;
            var sdsDataSourceUrl = "https://spatial.virtualearth.net/REST/v1/data/f42cab32d0ee41738d90856badd638d3/USCensus2010_ZCTA5/ZCTA5";

            function GetMap() {
                map = new Microsoft.Maps.Map('#myMap', {
                    center: new Microsoft.Maps.Location(40.10, -82.80),
                    zoom: 7
                });
            }

            function plotCensusData() {
                try {
                    
                    overlayLayer = new Microsoft.Maps.Layer("overlaylayer");
                 
                    map.layers.insert(overlayLayer);

                   var worldBounds = Microsoft.Maps.LocationRect.fromEdges(90, -180, -90, 180);    
                  
                   //Load the Bing Spatial Data Services module.
                    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {
                        //Create a query to get zip code tabulation areas in view.
                        var query = {
                            queryUrl: sdsDataSourceUrl,
                            inlineCount: true,
                            skip: 0,
                            top: 250,
                            spatialFilter: {
                                spatialFilterType: 'intersects',
                                intersects: worldBounds
                            }
                        };
                        //Trigger an initial search.
                        queryDataSource(query);
                    });


                } catch (e) {
                    alert("Error: " + e.message);
                }
            }
            function queryDataSource(query) {
                try {

                    //Process the query.
                    Microsoft.Maps.SpatialDataService.QueryAPIManager.search(query, map, function (data, inlineCount) {
                        counter++;

                        totalCensusQuery = inlineCount / 250;
                        var points = [];
                        for (var d = 0; data.length > d; d++) {

                            for (var ring = 0; data[d].getRings().length > ring; ring++) {
                                
                                var rings = data[d].getRings()[ring];
                                for (var ringCtr = 0; ringCtr < rings.length; ringCtr++) {
                                    points.push(rings[ringCtr]);
                                }
                            }
                        }

                        overlayLayer.add(data);
                       
                        //Increase the number of results to skip for the next query.
                        query.skip += query.top;
                       
                        //Check to see if there is more results to retrieve for this query. inlineCount is the total number of results for the query.
                        if (query.skip < inlineCount) {
                            //Query the next set of results.
                            queryDataSource(query);
                        }
                        else {
                            alert("All Done");
                        }
                    });
                } catch (e) {
                    alert("Error: " + e.message);
                }
            }      


        </script>
        <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key={{Bing map key}}' async defer></script>
    </head>
    <body>
        <button id="btnPlotCessus" onclick="plotCensusData()">Plot CensusData</button>
        <div id="myMap" style=";width:800px;height:600px;"></div>



    </body>
    </html>


    Balasaheb

    Friday, September 18, 2020 10:37 AM