Results 1 to 4 of 4

Thread: code for google location show palo altos before my location

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371

    Default code for google location show palo altos before my location

    hi,

    i have a problem for showing a map and my current location.

    I just want to precise i work on computer, a simple editor and i test it on Safari. I don't use phonegap.
    Cause it's maybe cause of the environment parameters...

    Someone can help me for the code please, cause after lot of researches, it's the only one code who display a map in my application. Then, i would like to keep this code, just don't understand why the app display palo altos during maybe 3 seconds.
    Viewport call simply homecard who display the map
    Code:
    items: [
            {xtype: 'homecard'},
            {xtype: 'infoscard'},
        ],
    And homecard:
    Code:
    myApp.views.Homecard = Ext.extend(Ext.Panel, {
        layout:'card',
        title: 'Infos',
        iconCls: 'home',
        
        initComponent: function(){
            var infowindow = new google.maps.InfoWindow({
                content: 'You are Here'
            });
            this.map = new Ext.Map({
                mapOptions : {
                    zoom: 12,
                    timeout: 10000,
                      maximumAge: 20000,
                    navigationControlOptions: {
                        style: google.maps.NavigationControlStyle.DEFAULT
                    },
                    autoUpdate:true,
                   },
                useCurrentLocation: true,
                listeners: {
                    maprender : function(comp, map){
                        var latlong = new google.maps.LatLng(comp.latitude, comp.longitude); // 45.936661, 6.630557
                        var marker = new google.maps.Marker({
                             position: latlong,
                             title : 'Here',
                             map: map
                        });
                        infowindow.open(map, marker);
                        google.maps.event.addListener(marker, 'click', function() {
                            infowindow.open(map, marker);
                        });
                    }
                }
            });
            this.panel = new Ext.Panel({
                layout:'fit',
                items:this.map,
                dockedItems:[
                    {
                        xtype:'toolbar',
                        title:'My Map',
                    }
                ]
            });
            this.items = this.panel;
            myApp.views.Homecard.superclass.initComponent.call(this);
        }
    });
    
    
    Ext.reg('homecard', myApp.views.Homecard);
    This code display me palo altos during 3 seconds, and display my good location after. But, markers don't work, I don't know why,
    Code:
    var latlong = new google.maps.LatLng(comp.latitude, comp.longitude); // 11.111111, 1.111111
    This code don't work. The marker is good when i give longitude and latitude
    11.111111, 1.111111
    , but not when i put
    comp.latitude, comp.longitude
    If you know why ...

    Thanks for your help

  2. #2
    Sencha User AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395

    Default

    Hy myput.
    If you take a look at the Ext.Map source code you will see what follows:

    Code:
    Ext.applyIf(me.mapOptions, {
       center: new gm.LatLng(37.381592, -122.135672), // Palo Alto
       zoom: 12,
       mapTypeId: gm.MapTypeId.ROADMAP
    });
    This means that if you don't specify your mapOptions center config param on Ext.Map component creation, it will display Palo Alto by default.
    So, if you want to display a different location, you should set the mapOptions center config (take at the Google docs at http://code.google.com/apis/maps/doc...reference.html).

    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  3. #3
    Sencha User edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939

    Default

    This is probably not the optimal behavior here... do you have a suggestion for how you'd like to see it defaulting instead?
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371

    Default

    Okey really thanks andreacammarata.

    I just add
    Code:
    center: new google.maps.LatLng(45.936661, 6.630557),
    in mapOptions and thats good. But now i have the same problem like before. If i want a real geoloc, with variables, who depends of the location,
    Code:
    var latlong = new google.maps.LatLng(comp.latitude, comp.longitude);
    Don't work; and in map option don't work too of course.

    How can i do for make working this code ? Which variables i must use. Cause i would like get many informations: (altitude, speed etc ...) but i don't know which contain do that, or if there is a special function for do that, in iphone, android, blackberry, and internet; is it the same google api function ? and which is it?

    thanks for help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •