PDA

View Full Version : Problem Display Marker (Marker infos are good)



myput
14 Sep 2011, 7:12 AM
Hello,
i have some problems for display the marker of current location.

When i put an alert with all informations of my currentPos Marker, all informations are Ok.
But the marker is not displayed.

Here is the code:


initComponent: function(){
//this.items = getMap();
var infowindow = new google.maps.InfoWindow();
var toolbar = new Ext.Toolbar({
dock: 'top',
xtype: 'toolbar',
title: 'Your Current Position',
});
var myMap = new Ext.Map({
getLocation: true,
mapOptions: {
zoom: 14,
}
});
new Ext.Panel({
fullscreen: true,
dockedItems: [toolbar],
items: [myMap],
});
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var detected = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);


var marker = new google.maps.Marker({
position: detected,
map: myMap.map,
});
alert(marker.map);
alert(marker.position);

contentString = "Vous etes ici!";
infowindow.setContent(contentString);
infowindow.setPosition(detected);
infowindow.open(myMap.map, marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(myMap.map, marker);
});


});
}
Ext.apply(this, {
items: [{
xtype: 'map',
useCurrentLocation: true,
map : google.maps.Map
}]
});
myApp.views.ShowCurrentPosMap.superclass.initComponent.call(this);
}

I don't understand why the marker don't work.

thanks for your Help :D

myput
15 Sep 2011, 1:06 AM
When i write at the end:


panel = Ext.apply(this, {
items: [{
xtype: 'map',
useCurrentLocation: true,
//map : google.maps.Map,
map: map.map,
}]
});
initial Code

If i write
map: this.map.map,
and not
map: map.map,

thats works but my tabPanel miss... I don't really understand.

If you have any ideas ...