0
請,有人可以解釋我怎麼可以管理,在這裏地圖代碼,nokia.maps.map.Display listener
和nokia.places.search.manager.geocode
方法?
我有地理編碼的標記,在地理編碼「oncomplete」中等待請求完成,然後在地圖顯示準備就緒時監聽,因此,如果它異步發生,它有時會在瀏覽器上顯示未完成的地圖,這是因爲map.zoomTo(bbox, false)
未被執行。諾基亞這裏地圖地理編碼和顯示地圖
如何管理這兩個事件?
<script type="text/javascript">
function goPageOnLoad() {
container = new nokia.maps.map.Container();
map = new nokia.maps.map.Display(document.getElementById('gmapcanvas'),
{ components:[ infoBubbles, new nokia.maps.map.component.Behavior(), new
nokia.maps.map.component.ZoomBar(), new
nokia.maps.map.component.Overview(), new
nokia.maps.map.component.TypeSelector(), new
nokia.maps.map.component.ScaleBar() ] });
addMarkersGeoLoc(map,container);
}
function addMarkersGeoLoc(map,container) {
countMarkerGeoLoc=1; coordinate = new
nokia.maps.geo.Coordinate(0, 0); startGeoCode('Via Roma 2, 16038 Santa
Margherita Ligure GE ');
}
function startGeoCode(addressStringt) {
nokia.places.search.manager.geoCode({
searchTerm : addressString,
onComplete: function(data, requestStatus){
if(data != null){
coordinate =
new nokia.maps.geo.Coordinate(data.location.position.latitude,
data.location.position.longitude);
var marker = new
nokia.maps.map.StandardMarker(coordinate, {brush: {color: "#FF0000"}});
marker.addListener(CLICK, function (evt) {
infoBubbles.openBubble(content, marker.coordinate); });
container.objects.add(marker);
managersFinished++;
}
else {
managersFinished++; alert('Address: '+addressString+', is not
localizable.');
}
if(managersFinished === countMarkerGeoLoc) {
map.objects.add(container);
map.set('zoomLevel', 14);
map.addListener("displayready", function() {
map.set('center',
[40.645304, 14.874063]);
bbox = container.getBoundingBox();
if(bbox !=null){
map.zoomTo(bbox, false);
}
});
}
}
});
}
</script>