1. #1
    Sencha User
    Join Date
    Jun 2012
    Location
    Roeselare, Belgium
    Posts
    4
    Vote Rating
    0
    JurgenL is on a distinguished road

      0  

    Default Unanswered: google maps through html in sencha, Cannot set property 'position' of undefined

    Unanswered: google maps through html in sencha, Cannot set property 'position' of undefined


    I'm trying to get google maps in my sencha touch app panel but without using the ext.Map variable (for school assignment purposes).

    What I've done is I've put a piece of html in the this.items and tried to get google maps into that piece of html.
    the error I get while debugging in Chrome: Uncaught TypeError: Cannot set property 'position' of undefined
    the reason for this is it can't properly read the html in this.items as a node (I think),
    but I also can't seem to find a way to select html automaticaly generated by sencha,
    so I have no idea how I can fix this

    Code:
    MyApp.views.MapPanel = Ext.extend(Ext.Panel,{
        title: 'Map',
        layout: 'fit',
        displayField: 'naam',
        initComponent: function(){
    
            var centerMap = new google.maps.LatLng(52.18958, 5.29524);
            var optionMap = {
                center: centerMap,
                zoom: 9,
                MapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
            this.items = [
                {
                    html: '<div id="map_canvas" style="width: 320px; height: 480px;"></div>'
                }
            ];
    
            var map = new google.maps.Map(this.items[0].html, optionMap);
    
            console.log(this.items[0].html);
    
            MyApp.views.MapPanel.superclass.initComponent.apply(this,arguments);
        }
    });
    
    Ext.reg('myapp-mappanel',MyApp.views.MapPanel);
    any help? I've tried everything...

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Location
    Roeselare, Belgium
    Posts
    4
    Vote Rating
    0
    JurgenL is on a distinguished road

      0  

    Default update on the matter

    update on the matter


    I've managed to get my map in but it doesn't work and it looks like this:
    Schermafbeelding 2012-06-05 om 14.07.29.jpg

    the updated code:
    Code:
    MyApp.views.MapPanel = Ext.extend(Ext.Panel,{
        title: 'Map',
        layout: 'fit',
        displayField: 'naam',
        initComponent: function(){
    
            var centerMap = new google.maps.LatLng(52.18958, 5.29524);
            var optionMap = {
                center: centerMap,
                zoom: 8,
                MapTypeId: google.maps.MapTypeId.ROADMAP
            };
    
            var canvas = document.createElement('div');
            canvas.id = 'map_canvas';
            canvas.style.width = '320px';
            canvas.style.height = '480px';
    
            var map = new google.maps.Map(canvas, optionMap);
    
            this.items = [
                {
                    html: canvas
                }
            ];
    
            //console.log(this.items[0].html);
            console.log(canvas);
    
            MyApp.views.MapPanel.superclass.initComponent.apply(this,arguments);
        }
    });
    
    Ext.reg('myapp-mappanel',MyApp.views.MapPanel);
    Nothing works so I can't zoom or scroll through the map and it won't rescale its size, setting width and height to 100% doesn't work either...

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    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


    Why aren't you using Ext.Map and add it as an item?
    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.

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Location
    Roeselare, Belgium
    Posts
    4
    Vote Rating
    0
    JurgenL is on a distinguished road

      0  

    Default


    according to our teacher it's easier and quicker to stylize the map this way...
    I kinda agree + she hands out the grades, I won't argue with her too much :p

    I found a solution for this problem btw...
    I made a separate JS-file and added the map api through there en through functions in that JS-file I'm able to send data from the database, adjust the map, and so on...

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    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


    Sorry to say it but she is wrong. Ext.Map just takes care of adding the google map in and sizing as it will then take part of the layouts.
    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
    Jun 2012
    Location
    Roeselare, Belgium
    Posts
    4
    Vote Rating
    0
    JurgenL is on a distinguished road

      0  

    Default


    I've never stylized an Ext.Map entirely, so I've never really compared, but stylizing the way I do right now is pretty easy so far.
    If our teacher is right... we can't be sure, but to be honest if I had a choice I would've stuck to Ext.Map...

Thread Participants: 1

Tags for this Thread