none
Spatial Data Service question RRS feed

  • Question

  • Hi,

    We have used below javascript code to get the census data using Microsoft.Maps.SpatialDataService but we want to do it using C#.

    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {

                        var worldBounds = Microsoft.Maps.LocationRect.fromEdges(90, -180, -90, 180);

                        //Get all states by doing an intersection test against a bounding box of the world and have up to 52 results returned.

                        var queryOptions = {

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

                            //spatialFilter: {

                            //    spatialFilterType: 'intersects',

                            //    intersects: worldBounds

                            //},

                            //"text-autospace:none;">                    };

                        Microsoft.Maps.SpatialDataService.QueryAPIManager.search(queryOptions, map, function (data) {

                            //Loop through results and set the fill color of the polygons based on the population property.

                            for (var i = 0; i < data.length; i++) {

                                data[i].setOptions({

                                    fillColor: getLegendColor(data[i].metadata.Population, maxPopulation)

                                });

                                //Add a click event to each polygon and display metadata.

                                Microsoft.Maps.Events.addHandler(data[i], 'click', function (e) {

                                    alert(e.target.metadata.Name + '\r\nPopulation: ' + e.target.metadata.Population);

                                });

                            }

                   

    Is anyone have sample code of C# to get region data as shown above.

    Thanks!


    Balasaheb

    Monday, June 22, 2020 12:13 PM

All replies

  • Tuesday, June 23, 2020 6:34 PM
  • Hi Ricky,

    Thanks for your reply. We will try it.

    Other issue we are facing, when we used above javascript. We have uploaded the shape file on bing map portal and try to get shape in our application using above mentioned javascript but we are getting below error. Same code works fine for other shape file that we uploaded but for some shape file it is not working.

    Below error it is throwing.

    Do you have solution for this issue.

    Thanks!


    Balasaheb

    Wednesday, June 24, 2020 10:52 AM
  • Hi,

    Anyone have solution for above issue.

    Thanks!


    Balasaheb

    Thursday, July 2, 2020 2:52 PM
  • Sorry, error is too small to read.  If it is an "Undefined" error. Likely the item you are calling is out of scope. That seems to be the most common issue.
    Thursday, July 2, 2020 8:40 PM
    Owner
  • Hi,

    The error is "Uncaught ReferenceError: Microsoft_Maps_Network_QueryAPI_1 is not definded".

    We have noticed when shape file has large number of polygon at that it throws above error. Do you have any solution for this issue.

    Waiting for your reply.

    Thanks!


    Balasaheb

    Tuesday, July 14, 2020 10:30 AM
  • Hi Balasaheb,

    Can you please provide full repro details?  I seem to get a little more info from you each time I ask so can you provide details of everything someone at Microsoft would need to see your issue?

    Along with the detail, you clarify the limit where the error begins to occur?

    Sincerely,

    IoTGirl

    Tuesday, July 14, 2020 5:41 PM
    Owner
  • Hi,

    We have uploaded USA zipcode shape file on our bing map portal as shown below.

    After upload we get the data source information as shown below. When we tried to query that shape file, we used query url

     

    We are using below code to execute above Query URL to get the shape file information from bing map.

    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService'function () {

                        var worldBounds = Microsoft.Maps.LocationRect.fromEdges(90, -180, -90, 180);

                        var queryOptions = {

                            queryUrl:"<<query url from bing map portal>>"

                               Microsoft.Maps.SpatialDataService.QueryAPIManager.search(queryOptions, map, function (data) {

                            //Loop through results and set the fill color of the polygons based on the population property.

                            for (var i = 0; i < data.length; i++) {

                                data[i].setOptions({

                                    fillColor: getLegendColor(data[i].metadata.Population, maxPopulation)

                                });

                                //Add a click event to each polygon and display metadata.

                                Microsoft.Maps.Events.addHandler(data[i], 'click'function (e) {

                                    alert(e.target.metadata.Name + '\r\nPopulation: ' + e.target.metadata.Population);

                                });

                            }

    We are able to read some of the postalcode (ploygon) after that it start throwing below error

    The error is "Uncaught ReferenceError: Microsoft_Maps_Network_QueryAPI_1 is not definded".

    Please check and let me know if you have any question or want more explanation.

    Thanks!


    Balasaheb

    Wednesday, July 22, 2020 10:59 AM
  • Hi Balasaheb,

    What call is happening right before this error?  You have all of the source code so you should be able to why this variable is unreferenced in that context.

    Sincerely,

    IoTGirl



    Wednesday, July 22, 2020 6:37 PM
    Owner
  • Hi,

    As there are more shapes are included that files. So It call recursively same function again and again until all shape are retrieve. As you know it will only retrieve 250 shapes at time and to get more shapes we have to call same function to read next shapes. The issue occurred after 3th or 4th call.

    Thanks!  


    Balasaheb

    Sunday, September 13, 2020 5:52 PM