Forked from FabiolaRamirez/VistaPrincipalViewController.m
Last active
August 29, 2015 14:05
-
-
Save alvareztech/eacd109dfc5f9876cc00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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]; | |
NSLog(@"****************"); | |
NSMutableArray * VectorAnotaciones=[[NSMutableArray alloc] init]; | |
PFQuery *query = [PFQuery queryWithClassName:@"Place"]; | |
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { | |
if (!error) { | |
NSLog(@"Successfully retrieved %i scores.", (int)objects.count); | |
CLLocationCoordinate2D Localizacion; | |
for (PFObject *object in objects) | |
{ | |
PFGeoPoint *geoPoint = (PFGeoPoint *)[object objectForKey:@"coordinate"]; | |
// asi se saca el titulo y la desc, igual que que el geopoint, osea igual que en todos los quetys que ya hicimos antes en las otras pantallas | |
NSString *nombre = (NSString *)[object objectForKey:@"name"]; | |
NSString *descripcion = (NSString *)[object objectForKey:@"description"]; | |
// ahora puedes usar esas variables donde sea... | |
NSLog(@"nombre: %@ descripcion: %@", nombre, descripcion); | |
float latitude1 = geoPoint.latitude; | |
float longitude1 = geoPoint.longitude; | |
//estructurando la annotation | |
Annotation *miAnotacion=[[Annotation alloc] init]; | |
Localizacion.latitude=latitude1; | |
Localizacion.longitude=longitude1; | |
miAnotacion.coordinate=Localizacion; | |
miAnotacion.title = nombre; | |
//miAnotacion.subtitle=(NSString *)place[@"name"]; | |
[VectorAnotaciones addObject:miAnotacion]; | |
[self.VistaMapa addAnnotations:VectorAnotaciones]; | |
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