none
Facing issue while setting best view mode in Bing Map V8. RRS feed

  • Question

  • Hi,

    I am creating multiple push pins and trying to set best view mode in Bing Map using Bing Map V8. It was not working,It is always showing my current location. same code is working with Bing Map v7 control. below is the sample code which i used in my app, please help on it.

    Here i am try to fetch locations from North America and India, which is not working. But if I fetch locations only from North America or near by locations best view mode is working.

    Both the scenarios working fine in Bing V7 control , please help me.


        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://www.bing.com/api/maps/mapcontrol"></script>
        <script type="text/javascript">
            var map = null;
            var boundValue = [];
            var locations = [{ "latitude": 31.46273, "longitude": -99.33304 }, { "latitude": 38.45222, "longitude": -123.11298 }, { "latitude": 35.843, "longitude": -86.34305 }, { "latitude": 39.44326, "longitude": -98.95734 }, { "latitude": 30.41364, "longitude": -84.13095 }, { "latitude": 44.04038, "longitude": -121.32028 }, { "latitude": 38.56117, "longitude": -121.7509 }, { "latitude": 30.41364, "longitude": -84.13095 }, { "latitude": 46.58976, "longitude": -112.0212 }, { "latitude": 44.04038, "longitude": -121.32028 }, { "latitude": 38.45222, "longitude": -123.11298 }, { "latitude": 30.41364, "longitude": -84.13095 }, { "latitude": 39.44326, "longitude": -98.95734 }, { "latitude": 47.67858, "longitude": -122.13158 }, { "latitude": 38.56117, "longitude": -121.7509 }, { "latitude": 47.67858, "longitude": -122.13158 }, { "latitude": 35.843, "longitude": -86.34305 }, { "latitude": 31.46273, "longitude": -99.33304 }, { "latitude": 17.45354, "longitude": 78.39476 }, { "latitude": 32.9865, "longitude": -96.68048 }, { "latitude": 26.16315722465515, "longitude": -97.79972769320011 }, { "latitude": 31.46273, "longitude": -99.33304 },
                { "latitude": 31.46273, "longitude": -99.33304 }];
           
            
            function getMap() {
                map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
                    credentials: 'Bing map key'
                });
                setPins();
              
                var options = { bounds: Microsoft.Maps.LocationRect.fromLocations(boundValue) };
                map.setView(options);
            }
           
            function setPins() {

                for (var i = 0; i < locations.length; i++) {
                    var cP = new Microsoft.Maps.Location(locations[i]["latitude"], locations[i]["longitude"])
                    boundValue.push(cP);
                    var pushpin = new Microsoft.Maps.Pushpin(cP, { text: i.toString(), color:new Microsoft.Maps.Color.fromHex('012fcb')});
                    map.entities.push(pushpin);
                }
            }
            
        </script>

    Thanks,

    Gowind

    Monday, June 6, 2016 2:41 PM

Answers

  • This is a known issue that has been fixed in the experimental branch. You can test this by adding &branch=experimental to the map script URL. This fix will be merged into the main release branch by the end of the month.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Monday, June 6, 2016 4:37 PM
    • Marked as answer by Gowind_ Tuesday, June 7, 2016 3:02 PM
    Monday, June 6, 2016 4:37 PM

All replies

  • This is a known issue that has been fixed in the experimental branch. You can test this by adding &branch=experimental to the map script URL. This fix will be merged into the main release branch by the end of the month.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Monday, June 6, 2016 4:37 PM
    • Marked as answer by Gowind_ Tuesday, June 7, 2016 3:02 PM
    Monday, June 6, 2016 4:37 PM
  • Hi Ricky,

    Thanks for your response, It is working fine with "experimental" branch.

    Thanks,

    Gowind

    Tuesday, June 7, 2016 3:03 PM