-1

안녕하세요 현재 위치에 마커를 배치하려고했지만 아래 코드가 로스 아틀라스로 되돌아갑니다. 마커를 꺼내면 내 위치를 찾습니다. 어떻게해야합니까? 마커가 작동합니까?Google지도가 로스 아토스에 위치를 유지합니다

Ext.define('FirstApp.view.Mapd',{ 
extend:'Ext.Panel', 
    xtype:'maps', 


    config : { 
     fullscreen: true, 
     layout: 'fit', 
     title:'Map', 
     iconCls:'map', 

     items: [{ 
      xtype: 'map', 

      mapOptions : { 
       useCurrentLocation: true, 
       zoom : 12, 
       mapTypeId : google.maps.MapTypeId.ROADMAP, 
       navigationControl: true, 
       navigationControlOptions: { 
        style: google.maps.NavigationControlStyle.DEFAULT 
       } 
      }, 

      listeners: { 


       maprender: function(comp, map) { 
        var marker = new google.maps.Marker({ 
        map : map, 
        position : map.center, 
        title : "Me", 
        animation: google.maps.Animation.BOUNCE 
         }); 

        setTimeout(function() { 
          map.panTo(map.center); 
        }, 1000); 
       } 
      } 
     }] 
    } 
}) 
+1

) 현재 위치에서 지금을 의미합니다. 그건 실종 된 것 같습니다. – Rafe

답변

0
명령의 주문이 모든 잘못

... 당신이 아래와 같이 지리적 메소드를 호출 & 업데이트를 해당 위치로 currentLocation를 현재 위치 찾기 아래 ::

  1. 순서를 따라야합니다 :

    mapOptions : { . . . 
         center : center 
         zoom : 15 
    }, 
    
    geo:new Ext.util.GeoLocation({ 
    
         autoUpdate:true, 
         maximumAge: 0, 
         timeout:2000, 
         listeners:{ 
          locationupdate: function(geo) { 
           center = new google.maps.LatLng(geo.latitude, geo.longitude); 
           if (map.rendered) 
            map.update(center) 
           else 
            map.on('activate', map.onUpdate, map, {single: true, data: center}); 
          }, 
          locationerror: function (geo,bTimeout, bPermissionDenied, bLocationUnavailable, message) { 
           if(bLocationUnavailable){ 
            alert('yayyyyour Current Location is Unavailable on this device'); 
           } 
           else if (bPermissionDenied){ 
            alert('Location capabilities have been disabled on this device.'); 
           }  
          } 
         } 
        }); 
    
  2. 다음은지도 마커를 추가 할 수 있습니다,지도 객체의 청취자에 maprender 이벤트를 추가합니다.
    위 단계를 완료하면 마침내지도가 마침내 현재 위치에 완벽하게 중점을두고 (오류 케이스가 발생하지 않음) 마커 개체를 만들고지도 개체의 가운데에 위치를 설정합니다. 우리의 현재 위치에 개체를 중심으로, 그 마커 당신은 마커 및 위치를 설정하는 코드의 조각을 포함 실제로 필요

    maprender : function(comp, map){ 
          var pos1; 
          pos1 = new google.maps.LatLng(lats, longs); 
          pos = pos1; 
          var marker = new google.maps.Marker({ 
           . . . . 
          }); 
          map.setMapTypeId(google.maps.MapTypeId.HYBRID); 
    
          setTimeout(function(){map.panTo (pos);} , 1000); 
         } 
    
+0

안녕하세요 귀하의 솔루션을 구현하려고했지만 불행히도 나는 다음과 같은 오류가 발생했습니다 : 잡히지 TypeError : 개체 # '방법'에 '어떤'이 될 수있는 아이디어가 무엇입니까? – paulpwr

관련 문제