1. #1
    Sencha Premium Member couetbis's Avatar
    Join Date
    Jan 2008
    Location
    Nantes - France
    Posts
    106
    Vote Rating
    1
    couetbis is on a distinguished road

      0  

    Default App build with Google Maps

    Hi,
    I have an app that use Google map.
    When I run command sencha app build testing
    or production I have this error :
    [ERROR] ReferenceError: Can't find variable: google
    Stack trace: http://localhost:8087/app/view/Carto.js?_dc=1344325889171 : 1 : Anonymous

    File in question :
    Code:
    Ext.define('PBGeo.view.Carto', {
      extend : 'Ext.Panel',
      xtype : 'carto',
      requires : [ 'Ext.Map','Ext.SegmentedButton'],
      config : {
        layout : 'fit',   
        items : [ {
          xtype : 'toolbar',
          docked : 'top',
          scrollable:true,
          items : [ {
            xtype: 'segmentedbutton',
            allowMultiple: true,
            defaults: {
              iconMask: true
            },
            items:[{iconCls : 'cinema', id:'cinema'},
                   {iconCls : 'resto', id:'resto'},
                   {iconCls : 'favorites', id:'favoris'}]
          } ]
        }, {
          xtype : 'map',
          flex: 1,
          id: 'carte',
          useCurrentLocation : false,
          mapOptions : {
            center : new google.maps.LatLng(47.214292,-1.556175),
            streetViewControl : false,
            panControl : false,
            zoom : 15,
            zoomControl : true,
            zoomControlOptions : {
              position : google.maps.ControlPosition.LEFT_CENTER
            }
          }
        } ]
      }
    });
    Script tag for API Map is in index.html.
    How to resolve this ?
    -->

  2. #2
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,212
    Vote Rating
    1045
    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

    This happens when your app files aren't downloaded and executed after the google maps JS file is downloaded and executed. This is because you are trying to create an instance as a property. Example:

    Code:
          mapOptions : {
            center : new google.maps.LatLng(47.214292,-1.556175)
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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 Premium Member couetbis's Avatar
    Join Date
    Jan 2008
    Location
    Nantes - France
    Posts
    106
    Vote Rating
    1
    couetbis is on a distinguished road

      0  

    Default

    Thanks for your reply but what is the solution ?

    I must center map on "maprender" event ?
    -->

  4. #4
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,212
    Vote Rating
    1045
    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

    Or use the applyMapOptions method in your own map subclass.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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.
    -->

  5. #5
    Sencha Premium Member couetbis's Avatar
    Join Date
    Jan 2008
    Location
    Nantes - France
    Posts
    106
    Vote Rating
    1
    couetbis is on a distinguished road

      0  

    Default

    Finally I have not succeeded to use applyMapOptions in a subclass so I choose to define map options in maprender events.

    Thanks for your help.
    -->

Thread Participants: 1

Tags for this Thread