Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvareztech/cff2215006029eb1d3e9 to your computer and use it in GitHub Desktop.
Save alvareztech/cff2215006029eb1d3e9 to your computer and use it in GitHub Desktop.
//
// VistaPrincipalViewController.m
// Proyecto2
//
// Created by Fabiola Ramirez on 29/06/14.
// Copyright (c) 2014 Fabiola Ramirez. All rights reserved.
//
#import "VistaPrincipalViewController.h"
#import "Annotation.h"
#import "SearchTableViewController.h"
#import <Parse/Parse.h>
@interface VistaPrincipalViewController ()
@end
// Coordenadas
//#define PZBicentenario_LATITUDE -16.505194;
//#define PZBicentenario_LONGITUDE -68.130090;
#define PZBicentenario_LATITUDE;
#define PZBicentenario_LONGITUDE;
#define PZIsabelCatolica_LATITUDE -16.509216;
#define PZIsabelCatolica_LONGITUDE -68.124225;
#define TBasilicaSanFrancisco_LATITUDE -16.496614;
#define TBasilicaSanFrancisco_LONGITUDE -68.137611;
#define TSanJoseRecoleta_LATITUDE -16.493100;
#define TSanJoseRecoleta_LONGITUDE -68.140176;
#define TNuestraSeñora_LATITUDE -16.496299;
#define TNuestraSeñora_LONGITUDE -68.134040;
#define MPedroMurillo_LATITUDE -16.495677;
#define MPedroMurillo_LONGITUDE -68.133478;
#define MAntonioJoseSucre_LATITUDE -16.504075;
#define MAntonioJoseSucre_LONGITUDE -68.131151;
#define MeBrujas_LATITUDE -16.496146;
#define MeBrujas_LONGITUDE -68.138865;
#define MuTamboQuirquincho_LATITUDE -16.493576;
#define MuTamboQuirquincho_LONGITUDE -68.137994;
#define MuLitoralBoliviano_LATITUDE -16.491912;
#define MuLitoralBoliviano_LONGITUDE -68.135619;
#define PMetropolitanoIkacota_LATITUDE -16.503678;
#define PMetropolitanoIkacota_LONGITUDE -68.123333;
//**
//SPAN
//#define SPAN 0.10f;
//**
@implementation VistaPrincipalViewController
//@synthesize VistaMapa;
- (void)viewDidLoad
{
[super viewDidLoad];
//mostrando vista de mapa
self.VistaMapa.delegate=self;
[self.VistaMapa setShowsUserLocation:YES];
//**
/*
//Hubicacion coordenada de PZBicentenario
CLLocationCoordinate2D LocalizacionCoordenadaPZBicentenario;
LocalizacionCoordenadaPZBicentenario.latitude=PZBicentenario_LATITUDE;
LocalizacionCoordenadaPZBicentenario.longitude=PZBicentenario_LONGITUDE;
//**
//Span
MKCoordinateSpan span;
span.latitudeDelta=SPAN;
span.longitudeDelta=SPAN;
//region
MKCoordinateRegion RegionPZBicentenario;
RegionPZBicentenario.center=LocalizacionCoordenadaPZBicentenario;
RegionPZBicentenario.span=span;
//envia la vista de mapa
[self.VistaMapa setRegion:RegionPZBicentenario animated:YES];
*/
//Anotaciones
NSMutableArray * VectorAnotaciones=[[NSMutableArray alloc] init];
CLLocationCoordinate2D Localizacion;
Annotation* miAnotacion;
PFObject *location=[[PFObject alloc]initWithClassName:@"Place"];
//Plaza Bicentenario
miAnotacion=[[Annotation alloc] init];
//double latitude1=[location[@"coordinate"] latitude];
//double longitude1=[location[@"coordinate"] longitude];
//miAnotacion.coordinate=;
miAnotacion.title=@"Plaza Bicentenario";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Plaza Isabel la Católica
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= PZIsabelCatolica_LATITUDE;
Localizacion.longitude=PZIsabelCatolica_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Plaza Isabel la Católica";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Basilica de San francisco
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= TBasilicaSanFrancisco_LATITUDE;
Localizacion.longitude=TBasilicaSanFrancisco_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Basilica de San francisco";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Templo San Jose de la Recoleta
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= TSanJoseRecoleta_LATITUDE;
Localizacion.longitude=TSanJoseRecoleta_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Templo San Jose de la Recoleta";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Templo Nuestra señora
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= TNuestraSeñora_LATITUDE;
Localizacion.longitude=TNuestraSeñora_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Templo Nuestra señora";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Monumento Pedro Domingo Murillo
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= MPedroMurillo_LATITUDE;
Localizacion.longitude=MPedroMurillo_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Monumento Pedro Domingo Murillo";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Monumento Antonio Jose de Sucre"
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= MAntonioJoseSucre_LATITUDE;
Localizacion.longitude=MAntonioJoseSucre_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Monumento Antonio Jose de Sucre";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Mercado de las Brujas
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= MeBrujas_LATITUDE;
Localizacion.longitude=MeBrujas_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Mercado de las Brujas";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Museo Tambo Quirquincho
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= MuTamboQuirquincho_LATITUDE;
Localizacion.longitude= MuTamboQuirquincho_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Museo Tambo Quirquincho";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Museo Litoral Boliviano
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= MuLitoralBoliviano_LATITUDE;
Localizacion.longitude=MuLitoralBoliviano_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Museo Litoral Boliviano";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
//Parke Metropolitano Laikacota
miAnotacion=[[Annotation alloc] init];
Localizacion.latitude= PMetropolitanoIkacota_LATITUDE;
Localizacion.longitude=PMetropolitanoIkacota_LONGITUDE;
miAnotacion.coordinate=Localizacion;
miAnotacion.title=@"Parke Metropolitano Laikacota";
miAnotacion.subtitle=@"Detalle";
[VectorAnotaciones addObject:miAnotacion];
[self.VistaMapa addAnnotations:VectorAnotaciones];
//crear una coordenada para usar con una anotacion
/*CLLocationCoordinate2D LocalizacionCoordenadaAnotacionPZBicentenario;
LocalizacionCoordenadaAnotacionPZBicentenario.latitude=PZBicentenario_LATITUDE;
LocalizacionCoordenadaAnotacionPZBicentenario.longitude=PZBicentenario_LONGITUDE;
Annotation * miAnotacion=[Annotation alloc];
miAnotacion.coordinate=LocalizacionCoordenadaAnotacionPZBicentenario;
miAnotacion.title=@"esto es un titulo";
miAnotacion.subtitle=@"Esto es un sutitulo";
[self.VistaMapa addAnnotation:miAnotacion];*/
NSLog(@"*********************************");
PFQuery *query = [PFQuery queryWithClassName:@"Place"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"Successfully retrieved %i scores.", (int)objects.count);
for (PFObject *object in objects)
{
PFGeoPoint *geoPoint = (PFGeoPoint *)[object objectForKey:@"coordinate"];
// aqui sacas otra informacion por ejemplo el nombre y descripcion del lugar para ponerlo en las anotaciones.
float latitude1 = geoPoint.latitude;
float longitude1 = geoPoint.longitude;
NSLog(@" Latitud: %f", latitude1);
NSLog(@" Longitud: %f", longitude1);
}
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}
}
//metodo mostrar User Location
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
//obteniendo coordenadas
CLLocationCoordinate2D miLocalizacionCoordenada1=[userLocation coordinate];
//zoom en la region
MKCoordinateRegion miRegion1= MKCoordinateRegionMakeWithDistance(miLocalizacionCoordenada1, 2500, 2500);
//Enviar vistadel mapa
[self.VistaMapa setRegion:miRegion1 animated:YES];
}
//**
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)buscar:(UIBarButtonItem *)sender {
// push
// SearchTableViewController *viewController = [[SearchTableViewController alloc] init];
SearchTableViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"searchTableViewController"];
[self.navigationController pushViewController:viewController animated:YES];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment