Abrufen Lage von FB und setzen Sie den marker auf der google map api für android

Ich versuche zu erstellen, der app store-Standort auf FB wenn der button speichern gedrückt wird, und abrufen von Standorten von FB und display-alle pins in der Karte. Ich war in der Lage, speichern von Standorten auf FB unter Speicherort Kind mit Längen-und Breitengrad, aber ich habe keine Ahnung, wie man die Werte und pins. Ich habe versucht, es zu tun die Weise, die FB hat es auf dem Handbuch, aber es hat nicht funktioniert. Kann mir jemand bei dem problem helfen?

Dies ist mein code bisher:

public class MapsActivity extends FragmentActivity implements 
OnMapReadyCallback {
private GoogleMap mMap;
private final static int MY_PERMISSION_FINE_LOCATION = 101;
private Button mSaveButton;
private DatabaseReference mDatabase;
private DatabaseReference refDatabase;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
//Obtain the SupportMapFragment and get notified when the map is ready to 
be used.
    SupportMapFragment mapFragment = (SupportMapFragment) 
    getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    mSaveButton = (Button) findViewById(R.id.Savebtn);
    mDatabase = 
FirebaseDatabase.getInstance().getReference().child("Navigation");
    refDatabase = 
FirebaseDatabase.getInstance().getReference().child("Location");
 }
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;


    mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {

        @Override
        public void onMapLongClick(LatLng point) {
            //TODO Auto-generated method stub

            //added marker saved as marker and coordinates passed to latlng
            Marker marker = mMap.addMarker(new 
           MarkerOptions().position(point));
            final LatLng latlng = marker.getPosition();

            mSaveButton.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View view){
                    DatabaseReference newPost = mDatabase.push();
                    newPost.child("Location").setValue(latlng);

                }
            });

          }
       });

       if (ActivityCompat.checkSelfPermission(this, 
    Manifest.permission.ACCESS_FINE_LOCATION) ==
             PackageManager.PERMISSION_GRANTED) {
        mMap.setMyLocationEnabled(true);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(new String[]
{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSION_FINE_LOCATION);
        }

    }


}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    switch (requestCode) {
        case MY_PERMISSION_FINE_LOCATION:
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
                        PackageManager.PERMISSION_GRANTED) {
                    mMap.setMyLocationEnabled(true);
                }

            }else {
                Toast.makeText(getApplicationContext(), "This requires location permissions to be granted", Toast
                        .LENGTH_LONG).show();
                finish();
            }
            break;
    }
  }
}

dies ist, wie die Lage gespeichert wurde in der Feuerstellung

Data
  -Kidp45TdInOM3Bsyu2b
         Location
         latitude:19.772613777905196 
         longitude:-9.92741011083126
  -KidsmTExZY2KjnS7S-b
         Location
         latitude: 18.221073689785065
         longitude: -6.573890447616577
  -KidvmAgV0bm2uT_Pcdr
         Location
         latitude: 14.44608051870992
         longitude: -6.510856859385967

InformationsquelleAutor Nis | 2017-04-26

Schreibe einen Kommentar