Skip to content

Instantly share code, notes, and snippets.

@FabiolaRamirez
Last active August 29, 2015 14:05
Show Gist options
  • Save FabiolaRamirez/eaa17949ada76ec24792 to your computer and use it in GitHub Desktop.
Save FabiolaRamirez/eaa17949ada76ec24792 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];
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"];
PFObject *place=[[PFObject alloc]initWithClassName:@"Place"];
// 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;
//estructurando la annotation
Annotation *miAnotacion=[[Annotation alloc] init];
Localizacion.latitude=latitude1;
Localizacion.longitude=longitude1;
miAnotacion.coordinate=Localizacion;
NSString*hello= miAnotacion.title=(NSString *)place[@"name"];
NSLog(@"%@ es:",hello);
//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