none
Henry County Virginia returns no Polygons RRS feed

  • Question

  • I am running this code inside my Bing Maps JavaScript file and the call for Henry

    County Virginia returns no Pologons. All of the other calls for AdminDivision2 and

    PopulatedPlaces works fine. Can someone please help?

    var SouthColor = newMicrosoft.Maps.Color( 100, 0, 100, 100 ); ColorEntity( "AdminDivision2", "Henry County Virginia", SouthColor ); function ColorEntity( EntityType, EntityName, PolygonColor ) { var geoDataRequestOptions = { entityType: EntityType }; Microsoft.Maps.loadModule( 'Microsoft.Maps.SpatialDataService', function () { //Use the GeoData API manager to get the boundary Microsoft.Maps.SpatialDataService.GeoDataAPIManager.getBoundary( EntityName, geoDataRequestOptions, map, function ( data ) { debugger; if ( data.results && data.results.length > 0 ) { for ( var i = 0, len = data.results[0].Polygons.length; i < len; i++ ) { data.results[0].Polygons[i].setOptions( { fillColor: PolygonColor, strokeColor: PolygonColor } ); } map.entities.push( data.results[0].Polygons ); } }, null, function errCallback( networkStatus, statusMessage ) { console.log( networkStatus ); console.log( statusMessage ); } ); } ); }



    MCSD Developer

    Friday, December 14, 2018 10:16 PM

Answers

  • Hi Ralph,

    Please note that not all entity types are available for all locations as described here: https://msdn.microsoft.com/en-us/library/dn306801.aspx

    When I enter this location on Bing Maps I get double sided area boundary.  See https://binged.it/2BpZUdG

    I then take a lat long from within that boundary and call the geodata API with AdminDivision2 https://www.bing.com/api/maps/sdk/mapcontrol/isdk/sdsloadsingleboundary and can confirm that data is there.

    You can paste the following code into the link above and press "Run" to see the same area boundary

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(36.682645, -79.926892),
        zoom: 10 });
    var geoDataRequestOptions = {
        entityType: 'AdminDivision2'
    };
    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {
        //Use the GeoData API manager to get the boundary
        Microsoft.Maps.SpatialDataService.GeoDataAPIManager.getBoundary(map.getCenter(), geoDataRequestOptions, map, function (data) {
            if (data.results && data.results.length > 0) {
                map.entities.push(data.results[0].Polygons);
            }
        }, null, function errCallback(networkStatus, statusMessage) {
            console.log(networkStatus);
            console.log(statusMessage);
        });
    });

    Does this solve the issue for you?

    Sincerely,

    IOTGirl

    • Marked as answer by RalphCEO Sunday, December 16, 2018 9:25 PM
    Sunday, December 16, 2018 5:48 PM
    Owner

All replies

  • Hi Ralph,

    Please note that not all entity types are available for all locations as described here: https://msdn.microsoft.com/en-us/library/dn306801.aspx

    When I enter this location on Bing Maps I get double sided area boundary.  See https://binged.it/2BpZUdG

    I then take a lat long from within that boundary and call the geodata API with AdminDivision2 https://www.bing.com/api/maps/sdk/mapcontrol/isdk/sdsloadsingleboundary and can confirm that data is there.

    You can paste the following code into the link above and press "Run" to see the same area boundary

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(36.682645, -79.926892),
        zoom: 10 });
    var geoDataRequestOptions = {
        entityType: 'AdminDivision2'
    };
    Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {
        //Use the GeoData API manager to get the boundary
        Microsoft.Maps.SpatialDataService.GeoDataAPIManager.getBoundary(map.getCenter(), geoDataRequestOptions, map, function (data) {
            if (data.results && data.results.length > 0) {
                map.entities.push(data.results[0].Polygons);
            }
        }, null, function errCallback(networkStatus, statusMessage) {
            console.log(networkStatus);
            console.log(statusMessage);
        });
    });

    Does this solve the issue for you?

    Sincerely,

    IOTGirl

    • Marked as answer by RalphCEO Sunday, December 16, 2018 9:25 PM
    Sunday, December 16, 2018 5:48 PM
    Owner
  • I took your code and studied it.  Then I changed my code line from 

    ColorEntity( "AdminDivision2", "Henry County Virginia", SouthColor );

    to

    ColorEntity( "AdminDivision2", Microsoft.Maps.Location(36.682645, -79.926892), SouthColor );

    Since the parameter of the GeoDataApiManager call takes a various type of inputs, the above line does work.  HOWEVER, there are only 3200+ counties in the US.  You would think that the Bing Spatial Data Services team would NOT BE LAZY and fix this !!!  There are many posts that complain about this type of issue where polygons result sets come back empty.

    Thanks for your help I really appreciate it.


    MCSD Developer


    • Edited by RalphCEO Sunday, December 16, 2018 9:26 PM
    Sunday, December 16, 2018 9:25 PM
  • Hi Ralph,

    Thanks for trying this out.  My suspicion is that because this polygon is essentially a donut, the confusion comes with the populated center in this case.  I have reported this to the SDS team that maintains this data for review.

    Sincerely,

    IoTGirl

    Sunday, December 16, 2018 10:33 PM
    Owner
  • No that is not true.  There are 44 independent cities in Virginia.  A few of them, but not all, I had to use PopulatedPlace to color in, some of which is the donut hole you describe.  I just think that it was a mistake or slight error in the service.  When I go directly to bing maps and type it in, there is no issue finding "Henry County Virginia" or "Henry County VA".  But thank you for reporting this, I am curious as to what you find.

    MCSD Developer

    Monday, December 17, 2018 12:00 AM