none
Not able to make background transparent of a single boundary map RRS feed

  • Question

  • Is it possible to make the background transparent. Only boundary line will be there.

    I'm using http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#sdsLoadSingleBoundary+JS

    Tuesday, March 21, 2017 9:20 AM

Answers

  • If you mean the map when you say background, yes, set the map type to Mercator:

    map.setView({
        mapTypeId: Microsoft.Maps.MapTypeId.mercator
    });


    [Blog] [twitter] [LinkedIn]

    Tuesday, March 21, 2017 3:56 PM
  • Ok, that is easy. Set the fill color of the polygon to transparent. Here is a sample:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
        center: new Microsoft.Maps.Location(43.7, -79.3834),
        zoom: 10
    });
    var geoDataRequestOptions = {
        entityType: 'PopulatedPlace'
    };
    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) {
    			for(var i=0;i<data.results[0].Polygons.length;i++){
    				data.results[0].Polygons[i].setOptions({fillColor:'transparent'})
    			}
                map.entities.push(data.results[0].Polygons);
            }
        });
    });
    


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, March 23, 2017 4:59 PM
    • Marked as answer by coderint Friday, March 24, 2017 7:12 AM
    Thursday, March 23, 2017 4:58 PM

All replies

  • If you mean the map when you say background, yes, set the map type to Mercator:

    map.setView({
        mapTypeId: Microsoft.Maps.MapTypeId.mercator
    });


    [Blog] [twitter] [LinkedIn]

    Tuesday, March 21, 2017 3:56 PM
  • I want to make the selected area transparent
    Thursday, March 23, 2017 11:03 AM
  • Ok, that is easy. Set the fill color of the polygon to transparent. Here is a sample:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
        center: new Microsoft.Maps.Location(43.7, -79.3834),
        zoom: 10
    });
    var geoDataRequestOptions = {
        entityType: 'PopulatedPlace'
    };
    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) {
    			for(var i=0;i<data.results[0].Polygons.length;i++){
    				data.results[0].Polygons[i].setOptions({fillColor:'transparent'})
    			}
                map.entities.push(data.results[0].Polygons);
            }
        });
    });
    


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, March 23, 2017 4:59 PM
    • Marked as answer by coderint Friday, March 24, 2017 7:12 AM
    Thursday, March 23, 2017 4:58 PM
  • Thanks
    Friday, March 24, 2017 7:12 AM