Displaying google map in android app with specified options
I'm new to android development and I had been trying to display a map in
my application for some time now. I finally managed to do it but I want to
display it with some specified options such as zoom level, location, etc
but its proving difficult.
The following is my .xml file
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
And the following is my .java file
package com.fourapps.cabkonnect;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import android.location.Location;
import android.graphics.Color;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
/**
* Created by nanakay on 6/6/13.
*/
public class Home extends FragmentActivity {
GoogleMap map;
private static final LatLng GOLDEN_GATE_BRIDGE = new
LatLng(37.828891,-122.485884);
private static final LatLng APPLE = new LatLng(37.3325004578,
-122.03099823);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
map = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (map == null) {
Toast.makeText(this, "Google maps not available",
Toast.LENGTH_LONG).show();
}
}
}
The map is displaying but I would want to display it with my own options.
I would be very happy if someone could help. Thanks
No comments:
Post a Comment