Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.phoenixpark.app;
- import java.util.ArrayList;
- import java.util.List;
- import android.annotation.SuppressLint;
- import android.app.AlertDialog;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.location.Criteria;
- import android.location.Location;
- import android.location.LocationListener;
- import android.location.LocationManager;
- import android.location.LocationProvider;
- 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 com.google.android.gms.maps.model.LatLng;
- import com.google.android.gms.maps.model.Marker;
- import com.google.android.gms.maps.model.MarkerOptions;
- public class MapPark extends FragmentActivity implements LocationListener
- {
- GoogleMap map;
- ArrayList<LatLng> markerPoints;
- Location location; // location
- LatLng phoenixpark;
- Location loc;
- protected LocationManager locationManager;
- protected LocationListener locationListener;
- protected String latitude,longitude;
- private LocalDbManager locations_db, food_db, parking_db;
- public String the_location;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.mappark_layout);
- // Initializing
- markerPoints = new ArrayList<LatLng>();
- // Getting reference to SupportMapFragment of the activity_main
- SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
- // Getting Map for the SupportMapFragment
- map = fm.getMap();
- Criteria criteria = new Criteria();
- // Getting the name of the best provider
- String provider = locationManager.getBestProvider(criteria, true);
- // Get the parks location
- location = locationManager.getLastKnownLocation(provider);
- phoenixpark = new LatLng(53.356065, -6.329665);
- // Zoom into the parks location when the activity starts
- map.moveCamera(CameraUpdateFactory.newLatLng(phoenixpark));
- map.animateCamera(CameraUpdateFactory.zoomTo(13));
- // add markers
- addMarkers();
- }
- // Add location markers to the map
- private void addMarkers()
- {
- MarkerOptions marker_name = new MarkerOptions().position(new LatLng
- (53.359772, -6.317010);
- marker_name.icon(BitmapDescriptorFactory.fromResource(R.drawable.attraction_icon));
- marker_name.title("Aras an Uachtarain");
- map.addMarker(marker_name);
- MarkerOptions marker_name2 = new MarkerOptions().position(new LatLng
- (53.355663, -6.304805);
- marker_name2.icon(BitmapDescriptorFactory.fromResource(R.drawable.attraction_icon));
- marker_name2.title("Dublin Zoo");
- map.addMarker(marker_name2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement