Hybrid View

  1. #1
    Sencha User
    Join Date
    Jun 2013
    Posts
    6
    Vote Rating
    0
    tmunro is on a distinguished road

      0  

    Default Essential whitespace removed from Ext.map map options

    Essential whitespace removed from Ext.map map options


    I'm trying to get a google map centered on a specific location by setting the map options via the inspector.
    I'm using Sencha Touch 2.2.1
    This is the contents of mapOptions:
    Code:
    {    center: new google.maps.LatLng(43.768732,11.256901),
     zoom: 16
    }
    Which I'm assuming gets broken when parsed, because in the view.js file it comes out as (note the missing whitespace between 'new' and 'google':
    Code:
    Ext.define('iFreshWebApp.view.MapLeaf', {    extend: 'Ext.Container',
    
    
        config: {
            id: 'MapLeaf',
            layout: {
                type: 'card'
            },
            scrollable: false,
            items: [
                {
                    xtype: 'map',
                    centered: false,
                    id: 'theMap',
                    itemId: 'mymap',
                    mapOptions: {
                        center: newgoogle.maps.LatLng(43.768732,
                        11.256901),
                        zoom: 16
                    }
                }
            ]
        }
    
    
    });
    This causes the app not to load. (newgoogle is undefined)

    I tried alternatively putting quotes around 'new google.maps.LatLng(43.768732,11.256901)' which caused the chrome console to output
    Code:
    Uncaught TypeError: Cannot use 'in' operator to search for 'longitude' in new google.maps.LatLng(43.768732,11.256901)
    Any help would be appreciated.

    Cheers

  2. #2
    Sencha - Architect Dev Team
    Join Date
    Jul 2012
    Posts
    291
    Vote Rating
    26
    honestbleeps will become famous soon enough honestbleeps will become famous soon enough

      0  

    Default


    thanks for the detailed report - we'll look into this shortly!
    Steve Sobel
    @honestbleeps
    Sencha Architect Development Team

  3. #3
    Sencha - Architect Dev Team
    Join Date
    Jul 2012
    Posts
    291
    Vote Rating
    26
    honestbleeps will become famous soon enough honestbleeps will become famous soon enough

      0  

    Default


    On reviewing your example - you're using a javascript expression as a config, which Architect doesn't support, so you have 2 options:

    1) you could define this in a controller action

    2) you could define the value in your initialize function (in ExtJS you'd use Process Config, but in touch, you'd do this in initalize)

    Hope that helps!
    Steve Sobel
    @honestbleeps
    Sencha Architect Development Team

  4. #4
    Sencha User
    Join Date
    Jun 2013
    Posts
    6
    Vote Rating
    0
    tmunro is on a distinguished road

      0  

    Default


    Thanks for your reply.
    Should something like this work for the initialise function?
    Code:
    listeners: [                    {
                            fn: function(component, eOpts) {
                                this.mapOptions = {center: new google.maps.LatLng(43.768732,11.256901), zoom: 1};
                            },
                            event: 'initialize'
                        }
                    ]
    I'm still having no luck.

  5. #5
    Sencha - Architect Dev Team
    Join Date
    Jul 2012
    Posts
    291
    Vote Rating
    26
    honestbleeps will become famous soon enough honestbleeps will become famous soon enough

      0  

    Default


    I'm pretty sure you'll actually want to do something like this:


    Code:
    Ext.define('iFreshWebApp.view.MapLeaf', {
        extend: 'Ext.Container',
        config: {      // ... your config code here ...    },
        initialize: function() {
            // since you're overriding, be sure to call the previous code...
            this.callParent();
            // set your config and/or run other code here... e.g.
            this.mapOptions = {center: new google.maps.LatLng(43.768732,11.256901), zoom: 1};
        }
    });
    Last edited by honestbleeps; 16 Jun 2013 at 10:38 PM. Reason: formatting
    Steve Sobel
    @honestbleeps
    Sencha Architect Development Team

  6. #6
    Sencha - Architect Dev Team
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    869
    Vote Rating
    32
    jminnick has a spectacular aura about jminnick has a spectacular aura about

      0  

    Default


    Just to be totally clear... initialize is a config option.... take a look at this:

    http://www.sencha.com/forum/showthre...map-component!
    Jason Minnick
    Sencha Architect Development Team

  7. #7
    Sencha User
    Join Date
    Jun 2013
    Posts
    6
    Vote Rating
    0
    tmunro is on a distinguished road

      0  

    Default


    That helps a lot. Thanks.