Ejemplo n.º 1
0
 @Override
 public boolean onMarkerClick(Marker marker) {
   // To get the GeoObject that owns the marker we use the following
   // method:
   GeoObject geoObject = mGoogleMapPlugin.getGeoObjectOwner(marker);
   if (geoObject != null) {
     String text = geoObject.getName();
     String description = CustomWorldHelper4.OBJECT_DESCRIPTION_MAP.get(geoObject);
     if (description != null) text = description;
     Toast.makeText(this, text, Toast.LENGTH_LONG).show();
   }
   return false;
 }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_google);

    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    if (mMap == null) {
      return;
    }

    // We create the world and fill the world
    mWorld = CustomWorldHelper4.generateObjects(this);

    // As we want to use GoogleMaps, we are going to create the plugin and
    // attach it to the World
    mGoogleMapPlugin = new GoogleMapWorldPlugin(this);
    // Then we need to set the map in to the GoogleMapPlugin
    mGoogleMapPlugin.setGoogleMap(mMap);
    // Now that we have the plugin created let's add it to our world.
    // NOTE: It is better to load the plugins before start adding object in to the world.
    mWorld.addPlugin(mGoogleMapPlugin);

    mMap.setOnMarkerClickListener(this);

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mGoogleMapPlugin.getLatLng(), 15));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(19), 2000, null);

    // Lets add the user position
    GeoObject user = new GeoObject(1_000L);
    user.setGeoPosition(mWorld.getLatitude(), mWorld.getLongitude());
    user.setImageResource(R.drawable.flag);
    user.setName("User position");
    mWorld.addBeyondarObject(user);

    BeyondarLocationManager.addWorldLocationUpdate(mWorld);
    BeyondarLocationManager.addGeoObjectLocationUpdate(user);
    BeyondarLocationManager.addLocationListener(this);
  }