I am using Google Maps with Android. I use the frame to view the map, and it works. However, I want to use the movement camera to focus the map in a specific place. However, I cannot implement it using my code.
MainActivity.java
public class MainActivity extends Activity { private MainMapFragement mapFragment; private HashMap<Marker, EventInfo> eventMarkerMap; EventInfo firstEventInfo; Marker firstMarker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_activity); mapFragment = new MainMapFragement(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.add(R.id.map, mapFragment); ft.commit(); } @Override protected void onStart() { super.onStart(); setUpEventSpots(); } private void setUpEventSpots() {
EventInfo.java
public class EventInfo { private LatLng latLong; private String name; private Date someDate; private String type; public EventInfo(LatLng latLong, String name, Date someDate, String type) { super(); this.latLong = latLong; this.name = name; this.someDate = someDate; this.type = type; } public LatLng getLatLong() { return latLong; } public void setLatLong(LatLng latLong) { this.latLong = latLong; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getSomeDate() { return someDate; } public void setSomeDate(Date someDate) { this.someDate = someDate; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
MapFragment.java
public class MainMapFragement extends MapFragment { public Marker placeMarker(EventInfo eventInfo) { Marker m = getMap().addMarker(new MarkerOptions() .position(eventInfo.getLatLong()) .title(eventInfo.getName())); return m; } }
Please how you implement it with this code.
source share