Results 1 to 3 of 3

Thread: Google Map keeps centering to current location

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    21
    Vote Rating
    1
      0  

    Default Google Map keeps centering to current location

    Hi all, my map displays two markers, my current location and another marker which has a lat and long. My map always seems to be centering to my current location. If I were to remove ' useCurrentLocation: true,', the map would display default locations with no markers. Is there a way in which I can center it to the other marker instead? Thank you!!

    Here's the map code:

    Code:
    Ext.define('demo.view.Mapo', {
        extend: 'Ext.Map',
        xtype:'mapo',
        config: {
            title:'Incident Location',
            iconCls:'maps',
            layout:'fit',
            draggable: true,
            useCurrentLocation: true,
            mapOptions: {
                zoom: 11,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
        },
        initialize: function(){
            var me = this;
            me.on('maprender', function(comp, map){
    		var image = 'resources/images/current.png';
    			new google.maps.Marker({
                    position: new google.maps.LatLng(
                            this._geo.getLatitude(), 
                            this._geo.getLongitude()
                    ),
    				icon: image,
                    map: map,
                    title: "Current Location",
                    animation: google.maps.Animation.DROP
                });
    		for (i=0; i<5; i++){
    		
    		var data = Ext.getStore('news').getData().items[i].data
    		};
                new google.maps.Marker({
                    position: new google.maps.LatLng(
                            data.Latitude, 
                            data.Longitude
                    ),
    				//icon: image,
                    map: map,
                    title: "Incident Location",
                    animation: google.maps.Animation.BOUNCE
                });
    			
    			
            });
            me.callParent(arguments);
        }
    });

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    This is because you have useCurrentLocation set to true. When the Geolocation class gets a new position it will center on that.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    91
    Vote Rating
    2
      0  

    Default

    Hello daftwolfie:

    I am running into same issue, did you get this resolved? Setting useCurrentLocation to false, renders the map at a different zoom level that I want .

    How can the refresh to center at current location be prevented?. Can you please share your solution if you've resolved it.

    Thanks.

Tags for this Thread

Posting Permissions

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