none
/Bug with setView({center}) on iPad when fired from puhpin click event? RRS feed

  • Question

  • I am populating the V7 Ajax control with custom pushpins from a GeoRSS file.

    I assign an "click" event to these pushpins. This event calls the following code when fired:

    setView({center: new Location(pushPin.latitude,pushPin.longitude), zoom: 11, animate: true});

    On most browsers (IE, Safari Desktop, Firefox) this works as I would expect it to - The map zooms to and centers on the pushpin when it is clicked.

    However, when I try the same operation on the iPad/iPhone, it seems that only the zoom portion of the command is carried out. The map never centers on the pushpin. I have tried various combinations of setView to no avail:

    setView({center: new Location(pushPin.lattitude,pushPin.longitude), zoom: 11, animate: true}); // Zoom only
    

    setView({center: new Location(pushPin.lattitude,pushPin.longitude), animate: true}); // Does nothing
    

     

    setView({zoom: 11, animate: true});
    
    // Short delay
    
    setView({center: new Location(pushPin.lattitude,pushPin.longitude), animate: true}); // Zoom only
    

     

    Only the zoom operation seems to work and never the center.

    Has anyone ever come across this or have any idea what is going on (or indeed, how I can investigate this further)?

    *Update*

    This behaviour only seems to happen when the setView code is executed from the function that handles the "click" event for my pushpin.

    If I call setView from a static button click for example, it works fine.

    Very odd behaviour.

    Cheers,

    Liam

     

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 11:51 AM (From:Bing Maps: Map Control and Web services Development)
    Sunday, August 21, 2011 10:15 AM

Answers

  • HI - the bug is fixed & would be out in upcoming release. No commitment on timeframe but could be early next month. Thanks for reporting & using Bing map control. 
    MSFT
    Hemant Goyal
    Friday, October 7, 2011 5:25 PM
  • Hi Hemant,

     

    I can confirm that this is now fixed.

     

    Cheers,

     

    Liam

    • Marked as answer by LiamWalshVW Wednesday, November 9, 2011 9:00 AM
    Wednesday, November 9, 2011 9:00 AM

All replies

  • Anybody have any ideas on this?

    Thursday, September 1, 2011 8:59 AM
  • Try new Microsoft.Maps.Location rather than new Location
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Thursday, September 1, 2011 9:11 AM
    Moderator
  • That is what it currently calls (the above new Location() code is merely shorthand for the purposes of this post).

     

    It works on all other browsers but not the iPad and it only seems to fail when fired from the pushpin click event handler.

    Thursday, September 1, 2011 9:41 AM
  • Right.... It's pretty tricky to debug other people's code when they've only told you it in shorthand ;)

    Can you post the actual code that is not working. A sample of your georss file would be useful too.


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Thursday, September 1, 2011 11:04 AM
    Moderator
  • OK, I'll cut out a lot of the irrelevant code in my scripts and post up code that can be used to reproduce the problem.

    Thursday, September 1, 2011 3:14 PM
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title>Maps Test</title>
    
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
    
      <script type="text/javascript" language="javascript">
    
        var map = null;
    
        // Initialises the map
        function Load() {
    
          // Declare the map options
          var options = { credentials: "<CREDENTIALS HERE>",
            enableClickableLogo: false,
            enableSearchLogo: false,
            mapTypeId: Microsoft.Maps.MapTypeId.road,
            center: new Microsoft.Maps.Location(55.36759662665731, -3.3922582619505847),
            zoom: 4
          };
    
          // Create the map and add it to the appropriate div
          map = new Microsoft.Maps.Map(document.getElementById('divMap'), options);
    
        }
    
        // Populates the map with some pushpins
        function PopulateMap() {
    
          // Zoom out
          map.setView({ center: new Microsoft.Maps.Location(55.36759662665731, -3.3922582619505847), zoom: 4 });
    
          // Clear all entities from the map
          map.entities.clear();
    
          // Create some shapes
          shape1 = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(50.36759662665731, -2.3922582619505847));
          shape2 = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(52.36759662665731, -3.3922582619505847));
          shape3 = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(57.36759662665731, -4.3922582619505847));
    
          // Assign click event handler to each
          pushpinClick = Microsoft.Maps.Events.addHandler(shape1, 'click', PinClick);
          pushpinClick2 = Microsoft.Maps.Events.addHandler(shape2, 'click', PinClick);
          pushpinClick3 = Microsoft.Maps.Events.addHandler(shape3, 'click', PinClick);
    
          // Add shapes to the map
          map.entities.push(shape1);
          map.entities.push(shape2);
          map.entities.push(shape3);
        }
    
        // Handles the click event for each pushpin
        function PinClick(e) {
    
          // Set center and zoom
          map.setView({ center: new Microsoft.Maps.Location(e.target.getLocation().latitude, e.target.getLocation().longitude), zoom: 11 });
    
        }
    
        function ZoomTopShape() {
    
          // Set center and zoom
          map.setView({ center: new Microsoft.Maps.Location(57.36759662665731, -4.3922582619505847), zoom: 11 });
    
        }
    
        function ZoomMiddleShape() {
    
          // Set center and zoom
          map.setView({ center: new Microsoft.Maps.Location(52.36759662665731, -3.3922582619505847), zoom: 11 });
    
        }
    
        function ZoomBottomShape() {
    
          // Set center and zoom
          map.setView({ center: new Microsoft.Maps.Location(50.36759662665731, -2.3922582619505847), zoom: 11 });
    
        }
    
    
      </script>
    
    </head>
    <body onload="Load()">
    
        <!-- Div which holds the map component -->
        <div id="divMap" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 1"></div>
    
        <div style="position: absolute; z-index: 2; top: 0px; left: 350px; width:800px; height: 30px">
          <input type="button" onclick="PopulateMap()" value="Populate Map"/>
          <input type="button" onclick="ZoomTopShape()" value="Zoom Top Shape"/>
          <input type="button" onclick="ZoomMiddleShape()" value="Zoom Middle Shape"/>
          <input type="button" onclick="ZoomBottomShape()" value="Zoom Bottom Shape"/>
        </div>
    
    </body>
    </html>
    


    You should be able to recreate the issue on the iPad using the above code. First click Populate Map to get some pins on there. Be sure to enter your Bing Maps key where it says CREDENTIALS HERE

    It works as I would expect it to on IE. When I run it from the iPad, the center operation never happens when I click/touch a pushpin. However, centering does work when I click one of the buttons (Zoom To buttons) for centering.

    Any help/further advice is much appreciated.

    Thursday, September 1, 2011 4:15 PM
  • Or just paste the URL of your map.
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Thursday, September 1, 2011 4:25 PM
    Moderator
  • URL Removed

    • Edited by LiamWalshVW Wednesday, November 9, 2011 8:59 AM
    Thursday, September 1, 2011 6:13 PM
  • I think I'm going to declare this as a bug. No one seems to be able to offer a great deal of advice on the issue at this moment in time.
    Wednesday, September 7, 2011 10:26 AM
  • Strange - it works fine on mac+Safari but not on iPad, iPhone. Thanks for reporting, the bug should be fixed in upcoming releases.

     

     


    MSFT
    Hemant Goyal
    Thursday, September 8, 2011 10:13 PM
  • Hi Hemant,

     

    Thanks for looking into this. Do you have any timescales for a release that fixes this bug?

     

    Cheers,

     

    Liam

    Friday, October 7, 2011 11:48 AM
  • HI - the bug is fixed & would be out in upcoming release. No commitment on timeframe but could be early next month. Thanks for reporting & using Bing map control. 
    MSFT
    Hemant Goyal
    Friday, October 7, 2011 5:25 PM
  • Hi Hemant,

     

    I can confirm that this is now fixed.

     

    Cheers,

     

    Liam

    • Marked as answer by LiamWalshVW Wednesday, November 9, 2011 9:00 AM
    Wednesday, November 9, 2011 9:00 AM