PDA

View Full Version : code for google location show palo altos before my location



myput
13 Sep 2011, 6:29 AM
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


items: [
{xtype: 'homecard'},
{xtype: 'infoscard'},
],

And homecard:


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,


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 :)

AndreaCammarata
13 Sep 2011, 7:44 AM
Hy myput.
If you take a look at the Ext.Map source code you will see what follows:




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/documentation/v3/reference.html).

Hope this helps.

edspencer
13 Sep 2011, 6:47 PM
This is probably not the optimal behavior here... do you have a suggestion for how you'd like to see it defaulting instead?

myput
13 Sep 2011, 11:20 PM
Okey really thanks andreacammarata. :D:D

I just add

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,
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 :">