-
3 Aug 2012 6:36 PM #1
Unanswered: Google Map keeps centering to current location
Unanswered: 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); } });
-
6 Aug 2012 5:29 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
This is because you have useCurrentLocation set to true. When the Geolocation class gets a new position it will center on that.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
24 Oct 2012 12:47 AM #3
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.


Reply With Quote