<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indie iPhone Development Blog &#187; google maps</title>
	<atom:link href="http://blog.indieiphonedev.com/tag/google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.indieiphonedev.com</link>
	<description>The musings of an independent iPhone developer</description>
	<lastBuildDate>Mon, 20 Jun 2011 18:48:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Elevation for routes</title>
		<link>http://blog.indieiphonedev.com/2010/04/09/elevation-for-routes/</link>
		<comments>http://blog.indieiphonedev.com/2010/04/09/elevation-for-routes/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 00:57:25 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[core location]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[iPhone app]]></category>

		<guid isPermaLink="false">http://blog.indieiphonedev.com/?p=173</guid>
		<description><![CDATA[I have been playing around with the GPS functionality of the iPhone for a while now and I think I have optimized the collection of in-plane GPS data as best as possible given the limitations of the hardware.  The iPhone was not created to be a garmin forerunner and this especially shines through when you [...]]]></description>
			<content:encoded><![CDATA[<p>I have been playing around with the GPS functionality of the iPhone for a while now and I think I have optimized the collection of in-plane GPS data as best as possible given the limitations of the hardware.  The iPhone was not created to be a garmin forerunner and this especially shines through when you try to get elevation data out of the iPhone GPS.  This became painfully obvious after I built the functionality for collecting and displaying elevation data from the GPS.  Even after creating sophisticated methods for filtering the GPS data and averaging the data and weighing the data by the vertical accuracy the graphs of the running data had no correlation with reality.  At first this was disappointing &#8211; I had created this great code for collecting, saving, and displaying the elevation data but clearly if I released an app which was going to show unrealistic elevation data &#8211; the app would get killed by bad reviews.</p>
<p>So I looked around for other places to get elevation data.  Turns out that the space station has used lasers to measure elevation all over the surface of the earth and that Google has an API which allows you to query that data.  This means much better resolution on the elevation data than a GPS (even a garmin) could ever provide and I can show elevation data for both current routes as well as routes that have been saved which have no elevation data saved with them.  The only issue is that a data connection is required in order to get at this data but the amount of data being sent back and forth is so small that the elevation data shows up almost instantly even on an EDGE connection.  Being a good citizen I only have the app request elevation data if the user is interested in seeing this type of data &#8211; this keeps data usage down and keeps load off Google&#8217;s servers.</p>
<p>The video below shows how the elevation data is displayed within the app.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/UzgwUBM23ww&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/UzgwUBM23ww&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.indieiphonedev.com%2F2010%2F04%2F09%2Felevation-for-routes%2F&amp;title=Elevation%20for%20routes" id="wpa2a_2"><img src="http://blog.indieiphonedev.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.indieiphonedev.com/2010/04/09/elevation-for-routes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone OS 4.0</title>
		<link>http://blog.indieiphonedev.com/2010/04/09/iphone-os-4-0/</link>
		<comments>http://blog.indieiphonedev.com/2010/04/09/iphone-os-4-0/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 15:45:39 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[iPhone OS]]></category>
		<category><![CDATA[multitasking]]></category>

		<guid isPermaLink="false">http://blog.indieiphonedev.com/?p=171</guid>
		<description><![CDATA[Great news for all the running/biking/hiking iPhone applications yesterday &#8211; OS 4.0 will not only allow you to run location based apps in the background &#8211; but you can now also have much richer overlays for maps.  These updates to the  iPhone OS will make it possible to make running apps that will really take [...]]]></description>
			<content:encoded><![CDATA[<p>Great news for all the running/biking/hiking iPhone applications yesterday &#8211; OS 4.0 will not only allow you to run location based apps in the background &#8211; but you can now also have much richer overlays for maps.  These updates to the  iPhone OS will make it possible to make running apps that will really take advantage of the iPhone hardware and bring great experiences to the active people using these apps.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.indieiphonedev.com%2F2010%2F04%2F09%2Fiphone-os-4-0%2F&amp;title=iPhone%20OS%204.0" id="wpa2a_4"><img src="http://blog.indieiphonedev.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.indieiphonedev.com/2010/04/09/iphone-os-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to test location and accelerometer functions from the comfort of your home</title>
		<link>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/</link>
		<comments>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 03:01:11 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[core location]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[iPhone app]]></category>
		<category><![CDATA[objective-C]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.indieiphonedev.com/?p=123</guid>
		<description><![CDATA[The LogYourRun iPhone app uses both the GPS and the accelerometer functions of the iPhone.  Neither the GPS nor the accelerometer can be accessed on the iPhone simulator so to circumvent this I used the following methods: Accelerometer: Otto Chrons has a great Google code project which contains the code for an app that can [...]]]></description>
			<content:encoded><![CDATA[<p>The LogYourRun iPhone app uses both the GPS and the accelerometer functions of the iPhone.  Neither the GPS nor the accelerometer can be accessed on the iPhone simulator so to circumvent this I used the following methods:</p>
<p><strong>Accelerometer: </strong> Otto Chrons has a great <a href="http://code.google.com/p/accelerometer-simulator/wiki/Home" target="_blank">Google code project</a> which contains the code for an app that can be run on an iPod touch or iPhone which is on the same subnet as your development computer.  The app will transmit accelerometer data which can be caught by some code that you can insert into your Xcode project.  When you run your app on the iPhone simulator it will thus receive the accelerometer data from the real life device.  This was a great help in troubleshooting the setup of the pedometer functionality.  I was running around in my living room counting steps and comparing to the # of steps on the iPhone simulator.  Be sure to remove the accelerometer simulator code from your application before releasing.</p>
<p><strong>GPS:</strong> Everyone who has played with the location manager on the iPhone Simulator knows that you will only get only one location from the location manager on the iPhone Simulator.  Testing the GPS functionality is a critical part of testing the LogYourRun app.  I could run the app on an iPhone and then run/walk/drive around outside &#8211; but that would take much too long and the weather in Saint Louis is not conductive to such testing.  Instead I added a button to the pedometer screen of the application which when clicked runs the following code:</p>
<pre class="brush: objc; title: ; notranslate">
- (IBAction) locationButton:(id)sender {
   CLLocation *thisLocation;
   double latitude  = 37.33168900 + (float) ((random() % 100) +1) / 1000000.0;
   double longitude = -122.03073100 + (float) ((random() % 100) +1) / 1000000.0;
   thisLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
   [self locationManager:locationManager didUpdateToLocation:thisLocation fromLocation:thisLocation];
   [thisLocation release];
}</pre>
<p>This piece of code creates a random location close to the location that the iPhone Simulator will usually get from the core location (One Infinite Loop).  The location is sent to the location manager delegate function of the pedometer class and is handled as if it came from the real location manager.  Since the location is different from the previous location the getDistanceFrom: still works.  When I am ready to submit the application all I have to do is hide the two buttons (probably should be done programatically &#8211; since one of these days I will forget).</p>
<div id="attachment_122" class="wp-caption aligncenter" style="width: 210px"><a href="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot.png"><img class="size-medium wp-image-122" title="Pedometer showing location and step button" src="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-200x300.png" alt="Pedometer showing location and step button" width="200" height="300" /></a><p class="wp-caption-text">The pedometer screen showing location and step button</p></div>
<p style="text-align: center;">
<div id="attachment_127" class="wp-caption aligncenter" style="width: 210px"><a href="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-2010.02.07-21.45.30.png"><img class="size-medium wp-image-127" title="Locations shown on map" src="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-2010.02.07-21.45.30-200x300.png" alt="Locations shown on map" width="200" height="300" /></a><p class="wp-caption-text">The random locations shown on map</p></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.indieiphonedev.com%2F2010%2F02%2F07%2Fhow-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home%2F&amp;title=How%20to%20test%20location%20and%20accelerometer%20functions%20from%20the%20comfort%20of%20your%20home" id="wpa2a_6"><img src="http://blog.indieiphonedev.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Encoding latitude and longitude the Google way</title>
		<link>http://blog.indieiphonedev.com/2010/01/22/encoding-latitude-and-longitude-the-google-way/</link>
		<comments>http://blog.indieiphonedev.com/2010/01/22/encoding-latitude-and-longitude-the-google-way/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 01:07:34 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[google polyline]]></category>
		<category><![CDATA[objective-C]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.indieiphonedev.com/?p=15</guid>
		<description><![CDATA[The LogYourRun iPhone App uses the GPS functionality of the iPhone to track running distance as well as the running route.  When data is uploaded from the app to the website the list of GPS coordinates have to be transferred from the phone to the website.  Since I already store route GPS data on the [...]]]></description>
			<content:encoded><![CDATA[<p>The LogYourRun iPhone App uses the GPS functionality of the iPhone to track running distance as well as the running route.  When data is uploaded from the app to the website the list of GPS coordinates have to be transferred from the phone to the website.  Since I already store route GPS data on the LogYourRun website as an encoded Google polyline I decided to have the iPhone encode the GPS data before sending to the website.  This takes processing load off the server and allows for faster transfer of data from the iPhone to the website.</p>
<p>I already have a JavaScript and a PHP version of the functions that both encode and decode GPS data as a Google polyline &#8211; so it was just a matter of converting the functions to Objective-C / Cocoa.</p>
<p>The way that the encoder works is first it multiples the coordinate by 10e5, takes the floor value and compares it to the coordinate to the 10e5 value of the previous coordinate and encodes the difference between the two points.  The following are functions used to perform the basic math.</p>
<p>This function is used to multiply the coordinate by 10e5:</p>
<pre class="brush: objc; title: ; notranslate">
- (int) floor1e5: (double) coordinate {
 return (int) floor(coordinate * 1e5);
}
</pre>
<p>This function is used to encode a signed number:</p>
<pre class="brush: objc; title: ; notranslate">
- (NSString *) encodeSignedNumber: (int) num {
int sgn_num = num &lt;&lt; 1;
 if (num &lt; 0) {
 sgn_num = ~(sgn_num);
 }
 return [self encodeNumber: sgn_num];
}
</pre>
<p>And this function is used to encode an unsigned int:</p>
<pre class="brush: objc; title: ; notranslate">
- (NSString *) encodeNumber: (int) num {
 int nextValue;
 NSMutableString *encodeString = [[NSMutableString alloc] initWithCapacity:5];
 [encodeString autorelease];

 while (num &amp;gt;= 0x20) {
 nextValue = (0x20 | (num &amp;amp; 0x1f)) + 63;
 [encodeString appendFormat:@&quot;%c&quot;, ((char) (nextValue))];
 num &amp;gt;&amp;gt;= 5;
 }

 num += 63;
 [encodeString appendFormat:@&quot;%c&quot;, ((char) (num))];

 return encodeString;
}
</pre>
<p>The following function is used to encode an array of CoreLocation objects (CLLocation *).  This array is called <em>locations</em> in the following code.  The  first thing the function does is to make sure that there are points in our <em>locations</em> assay.  Next I setup a mutable string which is going to contain the encoded polyline string as well as a temporary CoreLocation object (<em>tmploc</em>).  Since we have not started going through the locations we set the previous latitude and longitude to 0 each (<em>plat</em> and <em>plng</em>).  Then I go through the <em>locations</em> array and put them into the <em>temploc</em>.  For each location the previous latitude and longitude is subtracted from the current after the 1e5 conversion.  The encoded latitude and longitude are then added to the encoded polyline string which is returned at the end of the function.</p>
<pre class="brush: objc; title: ; notranslate">
- (NSString *) googlePolyline {
 int i, late5, lnge5, dlat, dlng, plat, plng;

 if ([locations count] == 0) {
 return @&quot;&quot;;
 }

 NSMutableString *encodedPoints = [[NSMutableString alloc] initWithCapacity:100];
 [encodedPoints autorelease];
 CLLocation *tmploc;

 plat = 0;
 plng = 0;

 for (i = 0; i &amp;lt; [locations count]; i++) {
 tmploc = [locations objectAtIndex:i];

 late5 = [self floor1e5: tmploc.coordinate.latitude];
 lnge5 = [self floor1e5: tmploc.coordinate.longitude];

 dlat = late5 - plat;
 dlng = lnge5 - plng;

 plat = late5;
 plng = lnge5;

 [encodedPoints appendFormat:@&quot;%@%@&quot;, [self encodeSignedNumber:dlat], [self encodeSignedNumber:dlng]];

 }
 return [[[NSString alloc] initWithFormat: @&quot;%@&quot;, encodedPoints] autorelease];
}
</pre>
<p>The googlePolyline function can be used to convert an array of location objects to a simple string which can then applied directly to a google map.</p>
<p>For other ports of the google polyline encoder see:</p>
<p><a href="http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/" target="_blank">http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/</a></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.indieiphonedev.com%2F2010%2F01%2F22%2Fencoding-latitude-and-longitude-the-google-way%2F&amp;title=Encoding%20latitude%20and%20longitude%20the%20Google%20way" id="wpa2a_8"><img src="http://blog.indieiphonedev.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.indieiphonedev.com/2010/01/22/encoding-latitude-and-longitude-the-google-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

