2014-04-25 3 views
0

각 위치마다 위도와 경도가 각각 3 개인 점포가 있습니다. 마커를 클릭하여 표준 Google 맵을 방향 FROM으로 엽니 다. 현재 사용자가 클릭 한 마커의 목적지에있는 경우, 이제는 사용자 위치를 얻는 것이 좋습니다. 마커를 클릭하여 스 니펫을 표시합니다. OK를 클릭하면 스 니펫이 튀어 나와 ("여기를 클릭하여 길 찾기") Google을 엽니 다. 이동할 수있는 Android 휴대 전화와 함께 표준으로 제공되는 MAPS?마커 Google 맵을 엽니 다.

Jave :

static final LatLng ARCADIA = new LatLng(-25.746318, 28.221322999999984); 
static final LatLng HATFIELD = new LatLng(-25.7487333, 28.238043199999993); 
static final LatLng CENTURION = new LatLng(-25.8602778, 28.189444399999957); 
private GoogleMap map; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_locate_store); 

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); 


    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 
    //map.setMapType(GoogleMap.MAP_TYPE_SATELLITE); 
    map.setMyLocationEnabled(true); 
    map.animateCamera(CameraUpdateFactory.zoomTo(5.0f)); 

     Marker aracdia = map.addMarker(new MarkerOptions().position(ARCADIA).title("Arcadia") 
       .snippet("Cnr Beatrix & Hamilton Street\n Contacts:\nTel: 076 7533 123\n click-for-directions") 
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small))); 
     Marker hatfield = map.addMarker(new MarkerOptions().position(HATFIELD).title("Hatfield").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small))); 
     Marker centurion = map.addMarker(new MarkerOptions().position(CENTURION).title("Centurion").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small))); 

답변

0

당신은 당신이 정보창을 클릭하고 당신이 그것을 클릭하면 표준 구글 맵 위치로 마커의 위치에 시작됩니다 의미한다.

먼저는 정보창에 대한 리스너를 추가해야합니다

myMap.setOnInfoWindowClickListener(
    new OnInfoWindowClickListener(){ 
    public void onInfoWindowClick(Marker marker){ 

    } 
    } 
); 
다음 다음 infowindowclick 내부 지리적 URI를 의도 만들

: 정확히 내가 필요로 할

myMap.setOnInfoWindowClickListener(
     new OnInfoWindowClickListener(){ 
     public void onInfoWindowClick(Marker marker){ 
      String uri = String.format(Locale.ENGLISH, "geo:%f,%f", marker.getPosition().latitude,marker.getPosition().longitude); 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
context.startActivity(intent); 
     } 
     } 
    ); 
+0

을 추가하려면 오류가 발생합니다. GoogleMap 형식의 setOnInfoWindowClickListener (GoogleMap.OnInfoWindowClickListener) 메서드는 인수에 사용할 수 없습니다 (new OnInfoWindowClickListener() {}). – TwoStarII

+0

@TwoStarII MapFragment를 사용하지 마십시오 (SupportMapFragment) getSupportFragmentManager(). findFragmentById (R.id.map); –

+0

나는 이미 가지고있는 것을 고수하고 싶다. 안드로이드 개발에 아직 익숙하지 않다. 스 니펫 상자를 클릭하면 MAPS 애플리케이션을 시작하거나 호출 할 수있다. – TwoStarII