Advertisement
colmulhall

Untitled

Apr 3rd, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.12 KB | None | 0 0
  1. package com.phoenixpark.app;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import android.annotation.SuppressLint;
  7. import android.app.AlertDialog;
  8. import android.content.Context;
  9. import android.content.DialogInterface;
  10. import android.location.Criteria;
  11. import android.location.Location;
  12. import android.location.LocationListener;
  13. import android.location.LocationManager;
  14. import android.location.LocationProvider;
  15. import android.os.Bundle;
  16. import android.support.v4.app.FragmentActivity;
  17. import android.view.Menu;
  18. import android.view.MenuItem;
  19. import android.widget.Toast;
  20.  
  21. import com.google.android.gms.maps.CameraUpdateFactory;
  22. import com.google.android.gms.maps.GoogleMap;
  23. import com.google.android.gms.maps.SupportMapFragment;
  24. import com.google.android.gms.maps.model.BitmapDescriptorFactory;
  25. import com.google.android.gms.maps.model.LatLng;
  26. import com.google.android.gms.maps.model.Marker;
  27. import com.google.android.gms.maps.model.MarkerOptions;
  28.  
  29. public class MapPark extends FragmentActivity implements LocationListener
  30. {
  31.     GoogleMap map;
  32.     ArrayList<LatLng> markerPoints;
  33.     Location location; // location
  34.     LatLng phoenixpark;
  35.     Location loc;
  36.     protected LocationManager locationManager;
  37.     protected LocationListener locationListener;
  38.     protected String latitude,longitude;
  39.     private LocalDbManager locations_db, food_db, parking_db;
  40.     public String the_location;
  41.  
  42.     @Override
  43.     protected void onCreate(Bundle savedInstanceState)
  44.     {
  45.         super.onCreate(savedInstanceState);
  46.         setContentView(R.layout.mappark_layout);
  47.        
  48.         // Initializing
  49.         markerPoints = new ArrayList<LatLng>();
  50.  
  51.         // Getting reference to SupportMapFragment of the activity_main
  52.         SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
  53.  
  54.         // Getting Map for the SupportMapFragment
  55.         map = fm.getMap();
  56.        
  57.         Criteria criteria = new Criteria();
  58.  
  59.         // Getting the name of the best provider
  60.         String provider = locationManager.getBestProvider(criteria, true);
  61.  
  62.         // Get the parks location
  63.         location = locationManager.getLastKnownLocation(provider);
  64.     phoenixpark = new LatLng(53.356065, -6.329665);
  65.  
  66.     // Zoom into the parks location when the activity starts
  67.     map.moveCamera(CameraUpdateFactory.newLatLng(phoenixpark));
  68.     map.animateCamera(CameraUpdateFactory.zoomTo(13));
  69.  
  70.     // add markers
  71.     addMarkers();
  72.     }
  73.  
  74.     // Add location markers to the map
  75.     private void addMarkers()
  76.     {
  77.          MarkerOptions marker_name = new MarkerOptions().position(new LatLng
  78.                         (53.359772, -6.317010);
  79.          marker_name.icon(BitmapDescriptorFactory.fromResource(R.drawable.attraction_icon));
  80.          marker_name.title("Aras an Uachtarain");
  81.          map.addMarker(marker_name);
  82.  
  83.      MarkerOptions marker_name2 = new MarkerOptions().position(new LatLng
  84.                         (53.355663, -6.304805);
  85.         marker_name2.icon(BitmapDescriptorFactory.fromResource(R.drawable.attraction_icon));
  86.         marker_name2.title("Dublin Zoo");
  87.         map.addMarker(marker_name2);
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement