bing-mapsbing

How to disable City names in Bing Maps V8


enter image description here

I've got the following map on my website initialised from js. How do I disable city names like how other countries are shown?


Solution

  • You can use a custom style as shown in the sample below:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>
    
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        
        <script>
        var map;
        var hiddenCityLabels = {
            "version": "1.0",
            "elements": {
                "point": {
                    "labelVisible": false,
                    "visible":false
                }
            }
        };
    
        function GetMap()
        {
            map = new Microsoft.Maps.Map('#myMap', {
                customMapStyle: hiddenCityLabels
            });
        }
        </script>
        
    </head>
    <body>
        <div id="myMap" style="position:relative;width:100%;height:600px;"></div>
    
         <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=<Your Bing Maps Key>'></script>
    </body>
    </html>