1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    2
    clubby is on a distinguished road

      0  

    Default [B1] setMapCenter positions the map center in the top-left corner

    [B1] setMapCenter positions the map center in the top-left corner


    When I call setMapCenter right after a map is created, the center-point I define is placed in the top-left corner of the map instead of the center. I didn't used to have this issue with pr3, when I set the map center after the maprender event. This event no longer seems to fire for me though. Any ideas for a fix?

    For context, I have a list of venues as one item in my root panel. When the user clicks on a list item, a tabPanel is added to the root panel, which has a map as one of its items.

    Code:
    onListItemSelect: function(myList, record) {
        var root = this.getRoot(),
              tabPanel = MyApp.view.myTabPanel.create(),
              myMap = this.getVenueMap(),  //an item in tabPanel
              lat = record.data.lat,
              lng = record.data.lng;
        root.add(tabPanel);
        root.setActiveItem(1);
        myMap.setMapCenter({latitude: lat, longitude: lng});
      }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Just testing this and it works...

    Code:
    var tabpanel = new Ext.tab.Panel({
        fullscreen : true,
        items      : [
            {
                xtype : 'map',
                title : 'Map'
            }
        ]
    });
    
    var map = tabpanel.down('map');
    
    map.setMapCenter({
        latitude  : 38.6271,
        longitude : 0-90.1998
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    2
    clubby is on a distinguished road

      0  

    Default


    Thanks for the help Mitchell. I am now executing setMapCenter in a setTimeout function (2 second delay), and then it worked.

    I think the issue may be that I tried to set the map position immediately after the tabPanel creating the map was created.

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default


    A safer way to center the map would be to listen for the map 'painted' event and call view.setMapCenter(location) inside the listener.

    Code:
    // There is a B1 bug in maprender, so use painted for now.
    mapView.on({'painted': function(view) {
    ...
        var location = somewhere;
    
        view.setMapCenter(location);
    });

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by bweiler View Post
    A safer way to center the map would be to listen for the map 'painted' event and call view.setMapCenter(location) inside the listener.

    Code:
    // There is a B1 bug in maprender, so use painted for now.
    mapView.on({'painted': function(view) {
    ...
        var location = somewhere;
    
        view.setMapCenter(location);
    });
    An even safer way is the maprender event
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default


    There's a bug in maprender in B1 so I used painted for now. The maprender bug should be fixed in B2.

  7. #7
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    2
    clubby is on a distinguished road

      0  

    Default


    Thanks for the insights.

    I had tried listening for maprender and painted using the control config option (I'm using MVC), but neither fired.

    I added a listener for painted using the method you mentioned, and it fires correctly. Is there now a way to call a function that I define in my controller?

    Code:
    Ext.define('MyApp.controller.MyController', {
      extend: 'Ext.app.Controller',
      config: {
        refs: {
          //refs go here
        },
        control: {
          myList: {
            select: 'onListItemSelect'
          }
        }
      },
      onListItemSelect: function() {
         MyApp.view.MyMap.create()  //create new panel
         MyMap.on('painted', function() {
            //
            //QUESTION:  How can I call updateMap from here??
            //
         }
      },
      updateMap: function() {
        //code to update map position
      }
    });

  8. #8
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default


    If I understand correctly, you want to call a function in your controller from within a view. If this is correct, I just found out the answer. See the link below:

    http://www.sencha.com/forum/showthre...ight=fireEvent

  9. #9
    Sencha User
    Join Date
    Apr 2011
    Posts
    40
    Vote Rating
    2
    clubby is on a distinguished road

      0  

    Default


    Awesome, that did the trick!

    Although, I should just be able to set a listener for "painted" in the control config, but that doesn't seem to work right now.

  10. #10
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default


    Quote Originally Posted by clubby View Post
    Awesome, that did the trick!

    Although, I should just be able to set a listener for "painted" in the control config, but that doesn't seem to work right now.
    I just tried it too and it didn't work. It looks like a bug in B1.

    Controller:
    Code:
     ...
     control: {
        'mapview': {
            painted: function() {console.log("map painted")},
     ...
    
    // xtype is mapview
    var mapView = Ext.create('MyApp.view.Map');

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."