Search Results

Search found 822 results on 33 pages for 'latitude longitude'.

Page 11/33 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • changing the saved contents of the model , edit model fileds once saved

    - by imran-glt
    hi I have extended the user model and added extra fields to it i.e "latitude" "longitude" and status and than save it. up to here it works fine. but i want to allow the user to change his/her "latitude" "longitude" whenever he/she needs like the hotmail and yahoo allows change account feature. in my case the user only wants to chage the latitude and longitude i tried it in this way but it didnt work. is this the right way to do it ...... or is there any other way to change the saved contents view.py def status_change(request): print "status_change function called" if request.method == "POST": rform = registerForm(data = request.POST) uform = UserForm(data = request.POST) if rform.is_valid(): user = uform.save() register = rform.save() register.user = user register.save() return render_to_response('home.html') else: rform = registerForm() return render_to_response('status_change.html',{'rform':rform})

    Read the article

  • Select records from XML column (SQL Server 2005) based on node order

    - by jdoe
    I have a column in a SQL Server 2005 table defined as an XML column. Is there a way to select records from this table based on the order of two nodes in that column? For example, we have the following structure in our XML: <item> <latitude/> <longitude/> </item> I want to see if there are any records that have latitude/longitude in the opposite order i.e. <longitude/> then <latitude/>. I've tried some XPath expressions but with no luck.

    Read the article

  • Accessing a variable passed by jquery using php

    - by celenius
    How does php access a variable passed by JQuery? I have the following code: $.post("getLatLong.php", { latitude: 500000}, function(data){ alert("Data Loaded: " + data); }); but I don't understand how to access this value using php. I've tried $userLat=$_GET["latitude"]; and $userLat=$_GET[latitude]; and then I try to print out the value (to check that it worked) using: echo $userLat; but it does not return anything. I can't figure out how to access what is being passed to it.

    Read the article

  • Either .each do or .all isn't working how I think it should

    - by user1299656
    So whenever someone rates a shop, I want the Shop model to calculate its new average rating and store that in the database (instead of calculating the average every time someone looks at it). So I wrote the segment of code that follows, and it doesn't work. The loop always iterates exactly once, no matter how many shop_ratings in the database exist that have the shop's id as their shop_id. I played around with it a bit and found that every time a new rating is submitted the function is called successfully, but it only runs the loop once and sets the average to what the first rating was. I don't know if the "query" that sets the ratings variable is wrong or if it's the loop that's wrong. class Shop < ActiveRecord::Base has_many :shop_ratings attr_accessible :name, :latitude, :longitude validates_presence_of :name validates_presence_of :latitude validates_presence_of :longitude def distance_to(lat, long) return (self.longitude - long) + (self.latitude - lat) end def find_average total = 0 count = 0 ratings = ShopRating.all(:conditions => {:shop_id => id}) ratings.each do |submission| total = total + submission.rating count = count + 1 end update_attribute :average_rating, total/count end end

    Read the article

  • How can I get the JSON array data from nsstring or byte in xcode 4.2?

    - by user1471568
    I'm trying to get values from nsdata class and doesn't work. here is my JSON data. { "count": 3, "item": [{ "id": "1", "latitude": "37.556811", "longitude": "126.922015", "imgUrl": "http://175.211.62.15/sample_res/1.jpg", "found": false }, { "id": "3", "latitude": "37.556203", "longitude": "126.922629", "imgUrl": "http://175.211.62.15/sample_res/3.jpg", "found": false }, { "id": "2", "latitude": "37.556985", "longitude": "126.92286", "imgUrl": "http://175.211.62.15/sample_res/2.jpg", "found": false }] } and here is my code -(NSDictionary *)getDataFromItemList { NSData *dataBody = [[NSData alloc] initWithBytes:buffer length:sizeof(buffer)]; NSDictionary *iTem = [[NSDictionary alloc]init]; iTem = [NSJSONSerialization JSONObjectWithData:dataBody options:NSJSONReadingMutableContainers error:nil]; NSLog(@"id = %@",[iTem objectForKey:@"id"]); //for Test output = [[NSString alloc] initWithBytes:buffer length:rangeHeader.length encoding:NSUTF8StringEncoding]; NSLog(@"%@",output); return iTem; } how can I access every value in the JSON? Please help me.

    Read the article

  • Get current location using CLLocationCoordinate2D

    - by Mobility
    I am trying to get current location of user using CLLocationCoordinate2D. I want the values in the format like CLLocationCoordinate2D start = {-28.078694,153.382844 }; So that I can use them like following: NSString *urlAddress = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, destination.latitude, destination.longitude]; I used CLLocation *location = [[CLLocation alloc]init ]; CLLocationDegrees currentLatitude = location.coordinate.latitude; CLLocationDegrees currentLongitude = location.coordinate.longitude; to get current lat & long. But I am getting 0.000 for both when I try to test. I am testing on iPhone 4s. If there is any sample code, it will be great.

    Read the article

  • Building a Store Locator ASP.NET Application Using Google Maps API (Part 3)

    Over the past two weeks I've showed how to build a store locator application using ASP.NET and the free <a href="http://code.google.com/apis/maps/">Google Maps API</a> and Google's geocoding service. <a href="http://www.4guysfromrolla.com/articles/051910-1.aspx">Part 1</a> looked at creating the database to record the store locations. This database contains a table named <code>Stores</code> with columns capturing each store's address and <a href="http://en.wikipedia.org/wiki/Latitude">latitude</a> and <a href="http://en.wikipedia.org/wiki/Longitude">longitude</a> coordinates. Part 1 also showed how to use Google's geocoding service to translate a user-entered address

    Read the article

  • Building a Store Locator ASP.NET Application Using Google Maps API (Part 2)

    Last week's article, <a href="http://www.4guysfromrolla.com/articles/051910-1.aspx">Building a Store Locator ASP.NET Application Using Google Maps API (Part 1)</a>, was the first in a multi-part article series exploring how to add store locator-type functionality to your ASP.NET website using the free <a href="http://code.google.com/apis/maps/">Google Maps API</a>. Part 1 started with an examination of the database used to power the store locator, which contains a single table named <code>Stores</code> with columns capturing the store number, its address and its <a href="http://en.wikipedia.org/wiki/Latitude">latitude</a> and <a

    Read the article

  • Building a Store Locator ASP.NET Application Using Google Maps API

    The past couple of projects I've been working on have included the use of the Google Maps API and geocoding service in websites for various reasons. I decided to tie together some of the lessons learned, build an ASP.NETstore locator demo, and write about it on 4Guys. Last week I published the first article in what I think will be a three-part series: Building a Store Locator ASP.NET Application Using Google Maps (Part 1). Part 1 walks through creating a demo where a user can type in an address and any stores within a (roughly) 15 mile area will be displayed in a grid.The article begins with a look at the database used to power the store locator (namely, a single table that contains one row for every location, with each location storing its store number, address, and, most important, latitude and longitude coordinates) and then turns to usingGoogle's geocoding service to translatea user-entered address into latitude and longitude coordinates. The latitude and longitude coordinates are used to find nearby stores, which are then displayed in a grid. Part 2 looks at enhancing the search results to include a map with markers indicating the position of each nearby store location. The Google Maps API, along with a bit of client-side script and server-side logic, make this actually pretty straightforward and easy to implement. Here's a screen shot of the improved store locator results. Part 3, which I plan on publishing next week, looks at how to enhance the map by using information windows to display address information when clicking a marker. Additionally, I'll show how to use custom icons for the markers so that instead of having the same marker for each nearby location the markers will be images numbered 1, 2, 3, and so on, which will correspond to a number assigned to each search result in the grid. The idea here is that by numbering the search results in the grid and the markers on the map visitors will quickly be able to see what marker corresponds to what search result. This article and demo has been a lot of fun to write and create, and I hope you enjoy reading it, too. Building a Store Locator ASP.NET Application Using Google Maps API (Part 1) Building a Store Locator ASP.NET Application Using Google Maps API (Part 2) Happy Programming!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Facebook - Publish Checkins using Graph API

    - by Zany
    I'm trying to publish Checkin using Facebook Graph API. I've gone through Facebook API documentation (checkins) and also have the publish_checkins permission. However, my checkin is not getting published. May I know is there anything wrong or am I missing anything else? Thank you for your time :) fbmain.php $user = $facebook->getUser(); $access_token = $facebook->getAccessToken(); // Session based API call if ($user) { try { $me = $facebook->api('/me'); if($me) { $_SESSION['fbID'] = $me['id']; $uid = $me['id']; } } catch (FacebookApiException $e) { error_log($e); } } else { echo "<script type='text/javascript'>top.location.href='$loginUrl';</script>"; exit; } $loginUrl = $facebook->getLoginUrl( array( 'redirect_uri' => $redirect_url, 'scope' => status_update, publish_stream, publish_checkins, user_checkins, user_location, user_status' ) ); main.php (Updated: 18/6/2012 11.12pm) <?php include_once "fbmain.php"; if (!isset($_POST['latitude']) && !isset($_POST['longitude'])) { ?> <html> <head> //ajax POST of latitude and longitude </head> <body> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({ appId: '<?php echo $facebook->getAppID() ?>', cookie: true, xfbml: true, oauth: true, frictionlessRequests: true }); FB.Canvas.setAutoGrow(); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script> ... <input type="button" value="Check In!" onclick="checkin(<?=$facebook?>);"/></span> </body> </html> <?php } else { print_r($_POST['latitude']); print_r($_POST['longitude']); ?> <script type="text/javascript"> // not using latitude and longitude to test function checkin($fb) { try { $tryCatch = $facebook->api('/'.$_SESSION['fbID'].'/checkins', 'POST', array( 'access_token' => $fb->getAccessToken(), //corrected 'place' => '165122993538708', 'message' =>'I went to placename today', 'coordinates' => json_encode(array( 'latitude' => '1.3019399200902', 'longitude' => '103.84067653695' )) )); } catch(FacebookApiException $e) { $tryCatch=$e->getMessage(); } return $tryCatch; } </script> <?php } ?>

    Read the article

  • setTimeout in javascript not giving browser 'breathing room'

    - by C Bauer
    Alright, I thought I had this whole setTimeout thing perfect but I seem to be horribly mistaken. I'm using excanvas and javascript to draw a map of my home state, however the drawing procedure chokes the browser. Right now I'm forced to pander to IE6 because I'm in a big organisation, which is probably a large part of the slowness. So what I thought I'd do is build a procedure called distributedDrawPolys (I'm probably using the wrong word there, so don't focus on the word distributed) which basically pops the polygons off of a global array in order to draw 50 of them at a time. This is the method that pushes the polygons on to the global array and runs the setTimeout: for (var x = 0; x < polygon.length; x++) { coordsObject.push(polygon[x]); fifty++; if (fifty > 49) { timeOutID = setTimeout(distributedDrawPolys, 5000); fifty = 0; } } I put an alert at the end of that method, it runs in practically a second. The distributed method looks like: function distributedDrawPolys() { if (coordsObject.length > 0) { for (x = 0; x < 50; x++) { //Only do 50 polygons var polygon = coordsObject.pop(); var coordinate = polygon.selectNodes("Coordinates/point"); var zip = polygon.selectNodes("ZipCode"); var rating = polygon.selectNodes("Score"); if (zip[0].text.indexOf("HH") == -1) { var lastOriginCoord = []; for (var y = 0; y < coordinate.length; y++) { var point = coordinate[y]; latitude = shiftLat(point.getAttribute("lat")); longitude = shiftLong(point.getAttribute("long")); if (y == 0) { lastOriginCoord[0] = point.getAttribute("long"); lastOriginCoord[1] = point.getAttribute("lat"); } if (y == 1) { beginPoly(longitude, latitude); } if (y > 0) { if (translateLongToX(longitude) > 0 && translateLongToX(longitude) < 800 && translateLatToY(latitude) > 0 && translateLatToY(latitude) < 600) { drawPolyPoint(longitude, latitude); } } } y = 0; if (zip[0].text != targetZipCode) { if (rating[0] != null) { if (rating[0].text == "Excellent") { endPoly("rgb(0,153,0)"); } else if (rating[0].text == "Good") { endPoly("rgb(153,204,102)"); } else if (rating[0].text == "Average") { endPoly("rgb(255,255,153)"); } } else { endPoly("rgb(255,255,255)"); } } else { endPoly("rgb(255,0,0)"); } } } } Ugh I don't know if that is properly formatted, I ended up with an extra bracket < So I thought the setTimeout method would allow the site to draw the polygons in groups so the users would be able to interact with the page while it was still drawing. What am I doing wrong here?

    Read the article

  • xml validation problem

    - by Hoax
    I'm having trouble validating a schema I created. "cvc-elt.1: Cannot find the declaration of element 'category'." xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="list"> <xs:complexType> <xs:sequence> <xs:element name="category" type="categoryType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="categoryType"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="desc" type="xs:string"/> <xs:element name="icon" type="xs:base64Binary"/> <xs:element name="poi" type="poiType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="poiType"> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="desc" type="xs:string"/> <xs:element name="longitude" type="xs:long"/> <xs:element name="latitude" type="xs:long"/> <xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="image" type="xs:base64Binary" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:schema> xml <?xml version="1.0" encoding="UTF-8"?> <list SchemaLocation="sem.xsd"> <category> <name>Sehenswürdigkeiten</name> <desc>sehenswerte und berühmte Orte, die man gesehen haben muss</desc> <icon>...</icon> <poi> <name>Linzer Landhaus</name> <desc>Sitz des Oberösterreichsichen Landtags</desc> <url>http://www.linz.at/tourismus/7569.asp</url> <longitude>48.304107</longitude> <latitude>14.286025</latitude> <image>...</image> </poi> <poi> <name>Ars Electronica</name> <desc>Museum der digitalen Künste</desc> <url>http://www.aec.at</url> <longitude>48.309788</longitude> <latitude>14.284179</latitude> <image>...</image> <image>...</image> </poi> </category> <category>...</category> </list> any idea whats wrong? cheers hoax

    Read the article

  • geofencing algorithm

    - by jose
    i have got a latitude and longitude of a point... i want to get all the readings of latitude and longitude with in a particular radius... is there any methods to calculate all laltitudes and longtiudes with in a radius with respect to a given point?...can u help me

    Read the article

  • NSFetchRequest returns correct number of objects, but each object contains nil attributes

    - by BU
    Hi, I can't figure out why this is happening. I can add to the context. But when I retrieve the objects, it returns the correct number of objects but the attributes of the objects are null. I am adding 3 instances with this code: +(BOOL)addStoreWithID:(NSNumber *)ID Latitude:(NSNumber *)latitude Longitude:(NSNumber *)longitude Name:(NSString *)name { Stores *store = (Stores *)[NSEntityDescription insertNewObjectForEntityForName:@"Stores" inManagedObjectContext:[[SharedResources instance] managedObjectContext]]; store.ID = ID; store.Latitude = latitude; store.Longitude = longitude; store.Name = name; NSError *error; if(![[[SharedResources instance] managedObjectContext] save:&error]) { //Handle the error return NO; } return YES; } I get the result: 2010-03-07 19:19:37.060 GamePouch_iPhone[11337:207] Store name is Starbucks (gdb) continue 2010-03-07 19:19:37.933 GamePouch_iPhone[11337:207] Store name is Dunkin Donuts (gdb) continue 2010-03-07 19:19:38.717 GamePouch_iPhone[11337:207] Store name is Krispy Kreme I have confirmed that this code is visited three times and none of the attributes are nil. Then when I try to retrieve it, I use the following code: +(NSMutableArray *)fetchAllObjects { NSFetchRequest *request; request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stores" inManagedObjectContext:[[SharedResources instance] managedObjectContext]]; [request setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"ID" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; NSError *error; NSMutableArray *array = [[[SharedResources instance] managedObjectContext] executeFetchRequest:request error:&error]; [request release]; [sortDescriptor release]; [sortDescriptors release]; for(int i=0;i<3;i++) { Stores *tempStore = (Stores *)[array objectAtIndex:i]; NSLog(@"store name is %@",[tempStore Name]); } return array; } I get the result: 2010-03-07 19:21:00.504 GamePouch_iPhone[11337:207] store name is (null) (gdb) continue 2010-03-07 19:21:01.541 GamePouch_iPhone[11337:207] store name is (null) (gdb) continue 2010-03-07 19:21:02.503 GamePouch_iPhone[11337:207] store name is (null) Thanks a lot for reading. Any help would be much appreciated. Thanks Bakhtiyar uddin

    Read the article

  • ReverseGeoCoder Fail Error in Mapkit

    - by Biranchi
    Hi All, I am making the ReverseGeoCoder request with the following latitude and longitude Latitude = 37.296740 Longitude = -122.001878 I am getting an error as "/SourceCache/ProtocolBuffer/ProtocolBuffer-19/Runtime/PBRequester.m:446 server returned error: 503" With the ReverseGeoCoder fail message as "Error Domain=PBRequesterErrorDomain Code=6001 "Operation could not be completed. (PBRequesterErrorDomain error 6001.)" What is this error due to ?? Any ideas ?? Thanks

    Read the article

  • Why do I get rows of zeros in my 2D fft?

    - by Nicholas Pringle
    I am trying to replicate the results from a paper. "Two-dimensional Fourier Transform (2D-FT) in space and time along sections of constant latitude (east-west) and longitude (north-south) were used to characterize the spectrum of the simulated flux variability south of 40degS." - Lenton et al(2006) The figures published show "the log of the variance of the 2D-FT". I have tried to create an array consisting of the seasonal cycle of similar data as well as the noise. I have defined the noise as the original array minus the signal array. Here is the code that I used to plot the 2D-FT of the signal array averaged in latitude: import numpy as np from numpy import ma from matplotlib import pyplot as plt from Scientific.IO.NetCDF import NetCDFFile ### input directory indir = '/home/nicholas/data/' ### get the flux data which is in ### [time(5day ave for 10 years),latitude,longitude] nc = NetCDFFile(indir + 'CFLX_2000_2009.nc','r') cflux_southern_ocean = nc.variables['Cflx'][:,10:50,:] cflux_southern_ocean = ma.masked_values(cflux_southern_ocean,1e+20) # mask land nc.close() cflux = cflux_southern_ocean*1e08 # change units of data from mmol/m^2/s ### create an array that consists of the seasonal signal fro each pixel year_stack = np.split(cflux, 10, axis=0) year_stack = np.array(year_stack) signal_array = np.tile(np.mean(year_stack, axis=0), (10, 1, 1)) signal_array = ma.masked_where(signal_array > 1e20, signal_array) # need to mask ### average the array over latitude(or longitude) signal_time_lon = ma.mean(signal_array, axis=1) ### do a 2D Fourier Transform of the time/space image ft = np.fft.fft2(signal_time_lon) mgft = np.abs(ft) ps = mgft**2 log_ps = np.log(mgft) log_mgft= np.log(mgft) Every second row of the ft consists completely of zeros. Why is this? Would it be acceptable to add a randomly small number to the signal to avoid this. signal_time_lon = signal_time_lon + np.random.randint(0,9,size=(730, 182))*1e-05 EDIT: Adding images and clarify meaning The output of rfft2 still appears to be a complex array. Using fftshift shifts the edges of the image to the centre; I still have a power spectrum regardless. I expect that the reason that I get rows of zeros is that I have re-created the timeseries for each pixel. The ft[0, 0] pixel contains the mean of the signal. So the ft[1, 0] corresponds to a sinusoid with one cycle over the entire signal in the rows of the starting image. Here are is the starting image using following code: plt.pcolormesh(signal_time_lon); plt.colorbar(); plt.axis('tight') Here is result using following code: ft = np.fft.rfft2(signal_time_lon) mgft = np.abs(ft) ps = mgft**2 log_ps = np.log1p(mgft) plt.pcolormesh(log_ps); plt.colorbar(); plt.axis('tight') It may not be clear in the image but it is only every second row that contains completely zeros. Every tenth pixel (log_ps[10, 0]) is a high value. The other pixels (log_ps[2, 0], log_ps[4, 0] etc) have very low values.

    Read the article

  • Storing an subtitle on an annotation with NSUserDefualts

    - by Krismutt
    Hey everybody! Basically: what i try to do is to save the street address of an annotation so that when I quit the application and launch it again the street address still will be there...see the following code: SavePosition.m -(NSString *)subtitle{ if (!subtitle) { return @"Ingen gata i närheten"; } else { return subtitle; } } -(NSString *)title{ return @"Sparad Position"; } -(id)initWithCoordinate:(CLLocationCoordinate2D) coor{ self.coordinate=coor; NSLog(@"%f,%f",coor.latitude,coor.longitude); return self; } - (void)setCoordinate:(CLLocationCoordinate2D)koor { MKReverseGeocoder *geocoder = [[[MKReverseGeocoder alloc] initWithCoordinate:koor] autorelease]; geocoder.delegate = self; coordinate = koor; [geocoder start]; } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error { NSLog(@"fail %@", error); } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { self.subtitle = [placemark.addressDictionary valueForKey:@"Street"]; } -(void)applicationWillTerminate:(UIApplication *)application { NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults]; [userDef setValue:subtitle forKey:@"SavedAddress"]; [userDef setBool:YES forKey:@"Street"]; [userDef synchronize]; } @end mainViewController.m -(void)viewDidLoad { [super viewDidLoad]; NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults]; if ([userDef boolForKey:@"sparadKoordinat-existerar"]) { CLLocationCoordinate2D savedCoordinate; savedCoordinate.latitude = [userDef doubleForKey:@"sparadKoordinat-latitud"]; savedCoordinate.longitude = [userDef doubleForKey:@"sparadKoordinat-longitud"]; SparaPosition *position=[[SparaPosition alloc] initWithCoordinate:savedCoordinate]; [mapView addAnnotation:position]; savedPosition = savedCoordinate; raderaSparad.enabled=YES; skickaMaps.enabled=YES; mStoreLocationButton.enabled=NO; friZoom = NO; NSString *savedAddress = [[NSUserDefaults standardUserDefaults] objectForKey:@"SavedAddress"]; if (savedAddress) { savedAddress.subtitle = [userDef valueForKey:@"Street"]; // what code should I add here? } MKCoordinateRegion region; region.center.latitude = savedCoordinate.latitude; region.center.longitude= savedCoordinate.longitude; MKCoordinateSpan span; span.latitudeDelta = 0.01; span.longitudeDelta = 0.01; region.span = span; region = [mapView regionThatFits:region]; [mapView setRegion:region animated:YES]; [mapView setRegion:region animated:TRUE]; }

    Read the article

  • find out the current location

    - by sairam333
    Hi , I want to dispaly the current location in my application not in map. I want the current palce using current lattitude and longitude . For Ex some 'x' person i want to know his location.but i want to know his location using his current lattitude and longitude.please give me the code suggestions for this.Thanks in advance

    Read the article

  • iPhone dev - showing two locations on the map

    - by Brian
    Now I have the coordinate of two locations, let say locationA with latitude 40 and longitude -80, locationB with latitude 30 and longitude -70, I want to create a mapView that I can see both locations with appropriate viewing distance. I got the new coordinate by finding the midpoint (in this example, {35, -75}), but the question is, How can I get an appropriate viewing distance? In particular, how can I calculate CLLocationDistance (if I'm using MKCoordinateRegionMakeWithDistance) or MKCoordinateSpan (if I'm using MKCoordinateSpanMake). Thanks in advance.

    Read the article

  • Finding City and Zip Code for a Location

    - by Kristopher Johnson
    Given a latitude and longitude, what is the easiest way to find the name of the city and the US zip code of that location. (This is similar to http://stackoverflow.com/questions/23572/latitude-longitude-database, except I want to convert in the opposite direction.) Related question: http://stackoverflow.com/questions/158557/get-street-address-at-latlong-pair

    Read the article

  • Get CoreLocation Update before TableView population?

    - by Clemens
    hi, i have the corelocation stuff in an uitableview controller. i actually want to get a distance from two locations and print that distance in a tableview cell. the problem is, that the tableview is filled before all the corelocation stuff happens. how can i make corelocation makes all updates before the table is filled? heres my class: // // EntriesListViewController.m // OEAW_App // // Created by Clemens on 6/6/10. // Copyright 2010 MyCompanyName. All rights reserved. // import "EntriesListViewController.h" import "EntryDetailController.h" @implementation EntriesListViewController @synthesize locationManager; @synthesize delegate; NSMutableDictionary *entries; NSMutableDictionary *dictionary; CLLocation *coords; /- (id) init { self = [super init]; if (self != nil) { self.locationManager = [[[CLLocationManager alloc] init] autorelease]; self.locationManager.delegate = self; } return self; }/ (CLLocationManager *)locationManager { if (locationManager != nil) { return locationManager; } locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; locationManager.delegate = self; return locationManager; } (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { //coords.longitude = newLocation.coordinate.longitude; //coords.latitude = newLocation.coordinate.latitude; coords = newLocation; NSLog(@"Location: %@", [newLocation description]); } (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"Error: %@", [error description]); } (void)viewDidLoad { //[[MyCLController alloc] init]; //[locationManager startUpdatingLocation]; [[self locationManager] startUpdatingLocation]; //---initialize the array--- //entries = [[NSMutableArray alloc] init]; //---add items--- //NSString *Path = [[NSBundle mainBundle] bundlePath]; //NSString *DataPath = [Path stringByAppendingPathComponent:@"Memorials.plist"]; dictionary = [[NSDictionary alloc] initWithContentsOfURL:[NSURL URLWithString: @"http://akm.madison.at/memorials.xml"]]; /*NSDictionary *dssItem = [dictionary objectForKey:@"1"]; NSString *text = [dssItem objectForKey:@"text"]; */ //entries = [[NSMutableDictionary alloc] init]; NSLog(@"%@", dictionary); //Path get the path to MyTestList.plist NSString *path=[[NSBundle mainBundle] pathForResource:@"Memorials" ofType:@"plist"]; //Next create the dictionary from the contents of the file. NSDictionary *dict=[NSDictionary dictionaryWithContentsOfFile:path]; //now we can use the items in the file. // self.name.text = [dict valueForKey:@"Name"] ; NSLog(@"%@",[dict valueForKey:@"Name"]); //---set the title--- self.navigationItem.title = @"Türkendenkmäler"; [super viewDidLoad]; } (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [dictionary count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... NSArray *keys = [dictionary allKeys]; id key = [keys objectAtIndex:indexPath.row]; NSDictionary *tmp = [dictionary objectForKey:key]; NSString *name = [tmp objectForKey:@"name"]; cell.textLabel.text = name; cell.font = [UIFont fontWithName:@"Helvetica" size:12.0]; CLLocation *location = [[CLLocation alloc] initWithLatitude:[[tmp valueForKey:@"coords_x"] floatValue] longitude:[[tmp valueForKey:@"coords_y"] floatValue]]; /*CLLocation *newLoc = [[CLLocation alloc] initWithLatitude:coords.latitude longitude:coords.longitude];*/ //locationController = [[MyCLController alloc] init]; int distance = [coords distanceFromLocation:location]; NSLog(@"%@",distance); cell.detailTextLabel.text = [NSString stringWithFormat:@"%@m",distance]; //NSLog(@"%@", [getLocation newLoc]); return cell; } (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { EntryDetailController *detailViewController = [[EntryDetailController alloc] initWithNibName:@"EntryDetailController" bundle:nil]; //detailViewController.entrySelected = [dictionary objectAtIndex:indexPath.row]; NSArray *keys = [dictionary allKeys]; id key = [keys objectAtIndex:indexPath.row]; NSDictionary *tmp = [dictionary objectForKey:key]; NSString *name = [tmp objectForKey:@"name"]; detailViewController.entrySelected_name = name; NSString *location = [tmp objectForKey:@"location"]; detailViewController.entrySelected_location = location; NSString *type = [tmp objectForKey:@"type"]; detailViewController.entrySelected_type = type; NSString *slug = [tmp objectForKey:@"slug"]; detailViewController.entrySelected_slug = slug; [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; } (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } (void)dealloc { [entries release]; [super dealloc]; } @end

    Read the article

  • Is there an easy way to type in common math symbols?

    - by srcspider
    Disclaimer: I'm sure someone is going to moan about easy-of-use, for the purpose of this question consider readability to be the only factor that matters So I found this site that converts to easting northing, it's not really important what that even means but here's how the piece of javascript looks. /** * Convert Ordnance Survey grid reference easting/northing coordinate to (OSGB36) latitude/longitude * * @param {OsGridRef} gridref - easting/northing to be converted to latitude/longitude * @returns {LatLonE} latitude/longitude (in OSGB36) of supplied grid reference */ OsGridRef.osGridToLatLong = function(gridref) { var E = gridref.easting; var N = gridref.northing; var a = 6377563.396, b = 6356256.909; // Airy 1830 major & minor semi-axes var F0 = 0.9996012717; // NatGrid scale factor on central meridian var f0 = 49*Math.PI/180, ?0 = -2*Math.PI/180; // NatGrid true origin var N0 = -100000, E0 = 400000; // northing & easting of true origin, metres var e2 = 1 - (b*b)/(a*a); // eccentricity squared var n = (a-b)/(a+b), n2 = n*n, n3 = n*n*n; // n, n², n³ var f=f0, M=0; do { f = (N-N0-M)/(a*F0) + f; var Ma = (1 + n + (5/4)*n2 + (5/4)*n3) * (f-f0); var Mb = (3*n + 3*n*n + (21/8)*n3) * Math.sin(f-f0) * Math.cos(f+f0); var Mc = ((15/8)*n2 + (15/8)*n3) * Math.sin(2*(f-f0)) * Math.cos(2*(f+f0)); var Md = (35/24)*n3 * Math.sin(3*(f-f0)) * Math.cos(3*(f+f0)); M = b * F0 * (Ma - Mb + Mc - Md); // meridional arc } while (N-N0-M >= 0.00001); // ie until < 0.01mm var cosf = Math.cos(f), sinf = Math.sin(f); var ? = a*F0/Math.sqrt(1-e2*sinf*sinf); // nu = transverse radius of curvature var ? = a*F0*(1-e2)/Math.pow(1-e2*sinf*sinf, 1.5); // rho = meridional radius of curvature var ?2 = ?/?-1; // eta = ? var tanf = Math.tan(f); var tan2f = tanf*tanf, tan4f = tan2f*tan2f, tan6f = tan4f*tan2f; var secf = 1/cosf; var ?3 = ?*?*?, ?5 = ?3*?*?, ?7 = ?5*?*?; var VII = tanf/(2*?*?); var VIII = tanf/(24*?*?3)*(5+3*tan2f+?2-9*tan2f*?2); var IX = tanf/(720*?*?5)*(61+90*tan2f+45*tan4f); var X = secf/?; var XI = secf/(6*?3)*(?/?+2*tan2f); var XII = secf/(120*?5)*(5+28*tan2f+24*tan4f); var XIIA = secf/(5040*?7)*(61+662*tan2f+1320*tan4f+720*tan6f); var dE = (E-E0), dE2 = dE*dE, dE3 = dE2*dE, dE4 = dE2*dE2, dE5 = dE3*dE2, dE6 = dE4*dE2, dE7 = dE5*dE2; f = f - VII*dE2 + VIII*dE4 - IX*dE6; var ? = ?0 + X*dE - XI*dE3 + XII*dE5 - XIIA*dE7; return new LatLonE(f.toDegrees(), ?.toDegrees(), GeoParams.datum.OSGB36); } I found that to be a really nice way of writing an algorythm, at least as far as redability is concerned. Is there any way to easily write the special symbols. And by easily write I mean NOT copy/paste them.

    Read the article

  • Jquery mobile and Google maps [on hold]

    - by Jack
    I have been trying to get my google maps to display within a page of a mobile app. The map will display for a second, and then disappear. I have read about a jquery bug, but i can't seem to find a way to get this code to work. any help would be greatly appreciated. <script> var geocoder; var currentLocation; var searchResults; var map; var directionsDisplay; var directionsService; function init(){ geocoder = new google.maps.Geocoder(); if (navigator.geolocation){ navigator.geolocation.watchPosition(showLocation, locationError); } else { alert("Geolocation not supported on this device"); return; } }//init function function showLocation(location){//start showlocation currentLocation = new google.maps.LatLng(location.coords.latitude, location.coords.longitude); $('#lat').attr("value", currentLocation.lat()); $('#lng').attr("value", currentLocation.lng()); geocoder = new google.maps.Geocoder(); geocoder.geocode({'latLng': currentLocation}, function(results, status){ if (status == google.maps.GeocoderStatus.OK){ if (results[0]){ var address = results[0].formatted_address; $('#loc').html(results[0].formatted_address); var info = "Latitude: " + location.coords.latitude + " Longitude: " + location.coords.longitude + "<br />"; info += "Location accurate within " + location.coords.accuracy + " meters <br /> Last Update: " + new Date(location.timestamp).toLocaleString(); $('#acc').html(info); $('#address').attr("value", results[0].formatted_address); }else{ alert('No results found'); }//end else //if(!map) initMap(); }else { $('#loc').html('Geocoder failed due to: ' + status); }//end else });//end of function if (!map) initMap(); }//end showlocation function function locationError(error){ switch(error.code) { case error.PERMISSION_DENIED: alert("Geolocation access denied or disabled. To enable geolocation on your iPhone, go to Settings > General> Location Services"); break; case error.POSITION_UNAVAILABLE: alert("Current location not available"); break; case error.TIMEOUT: alert("Timeout"); break; default: alert("unkown error"); break; }//endswitch }//endlocationerror function initMap(){ var mapOptions = { zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP, center: currentLocation };//var mapOptions map = new google.maps.Map(document.getElementById('mapDiv'), mapOptions); google.maps.event.trigger(map, 'resize'); var bounds = new google.maps.LatLngBounds(); bounds.extend(currentLocation); map.fitBounds(bounds); //new code //var center; //function calculateCenter(){ //center = map.getCenter(); //} //google.maps.even.addDomListener(map, 'idle', function(){ //calculateCenter(); //}); //google.maps.even.addListenerOnce(map, 'idle', function(){ //google.maps.even.trigger(map,'resize'); //}); //google.maps.event.addDomListener(window, 'resize', function() { //map.setCenter(center); //});//end new code }//end initMap() //------------------------------------------------------------------------------- $(document).on("pageinit", init);

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >