<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; Google Maps</title>
	<atom:link href="http://devblog.blackberry.com/tag/google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Tue, 18 Jun 2013 16:50:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; Google Maps</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Maps. They Don’t Love You Like I Love You.</title>
		<link>http://devblog.blackberry.com/2012/12/blackberry-webworks-maps/</link>
		<comments>http://devblog.blackberry.com/2012/12/blackberry-webworks-maps/#comments</comments>
		<pubDate>Tue, 04 Dec 2012 15:17:42 +0000</pubDate>
		<dc:creator>chadtatro</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[WebWorks]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[Bing Maps]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[Leaflet]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[OpenLayers]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[webworks]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=12521</guid>
		<description><![CDATA[Forget everything you know about working with maps and BlackBerry WebWorks. Mapping just got real, real easy! We heard you ask for an easy way to integrate mapping services with your BlackBerry WebWorks applications, and today I’m happy to announce that on BlackBerry 10, the process has become much simpler. We&#8217;ve put together a straight-forward sample [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=12521&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-12522" alt="TITLE_IMAGE" src="http://rimdevblog.files.wordpress.com/2012/12/webworks-maps.jpg?w=600&#038;h=364" height="364" width="600" /></p>
<p>Forget everything you know about working with maps and BlackBerry WebWorks. Mapping just got real, real easy!</p>
<p>We heard you ask for an easy way to integrate mapping services with your BlackBerry WebWorks applications, and today I’m happy to announce that on BlackBerry 10, the process has become much simpler.</p>
<p>We&#8217;ve put together a straight-forward sample application that will show you how to integrate with a few of the services out there:  Google Maps, Bing, Leaflet, and OpenLayers.</p>
<p>If you&#8217;ve been following the progression of the BlackBerry WebWorks framework, you&#8217;ve probably noticed an awesome amount of transparency. Open web standards are lovingly embraced and adopted here at RIM. Even the framework itself is staged publicly on GitHub.  Continuing this theme of openness and following web standards, the maps samples we&#8217;ve released are not platform specific.  Whether you’re writing an exclusive BlackBerry app, or planning on targeting multiple platforms using Cordova (previously known as PhoneGap), these samples are most definitely for you!</p>
<p><span id="more-12521"></span></p>
<p>For each service, you’ll be able to learn how to:</p>
<p>-          Setup a mapping service to use to in your app</p>
<p>-          Find the users location with HTML5 Geolocation</p>
<p>-          Perform a search for nearby points of interest</p>
<p>-          Display push-pins on the map, showing the search results.</p>
<p>The goal of this sample is to show you how you can quickly integrate maps into your app and have it perform great in WebWorks for BlackBerry 10.</p>
<p>When it comes down to picking which service is right for your app, it’s completely up to you.  One of my teammates, Jim Ing, wrote a really in-depth article on maps, comparing services and much more.  I strongly recommend checking it out “<a href="http://devblog.blackberry.com/2012/05/lightweight-maps-for-mobile-part-1/" target="_blank">Lightweight Maps For Mobile</a>”.</p>
<p><b>Check out the sample, in action!</b></p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/lSn3rex7PCI?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><b>Download the source code.</b></p>
<p>Ready to add some maps to your app? Download the source code from <a href="https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/Maps" target="_blank">our GitHub repository</a>!</p>
<p><b>Calling all Native developers!</b></p>
<p>Have you been yearning to contribute to the BlackBerry 10 cause but weren’t sure how?  Why not take this WebWorks sample, and build a Native version?!  If you’re interested, get in touch with Shadid Haque (<a href="http://twitter.com/ShadidHaque" target="_blank">@ShadidHaque</a>) on Twitter.</p>
<p>If you&#8217;ve got a success story, have a question, or just want to chat about apps, hit me up on Twitter <a href="http://www.twitter.com/chadtatro" target="_blank">@chadtatro</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/12521/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/12521/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=12521&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/12/blackberry-webworks-maps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0fb86e7b2b71616806266b535686102c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ctetreault1980</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/12/webworks-maps.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>
	</item>
		<item>
		<title>Lightweight Maps for Mobile, Part 1: Introduction to Map APIs and Libraries</title>
		<link>http://devblog.blackberry.com/2012/05/lightweight-maps-for-mobile-part-1/</link>
		<comments>http://devblog.blackberry.com/2012/05/lightweight-maps-for-mobile-part-1/#comments</comments>
		<pubDate>Tue, 08 May 2012 13:18:17 +0000</pubDate>
		<dc:creator>Jim Ing</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[apis]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[MapQuest]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[mobile web apps]]></category>
		<category><![CDATA[tile naming conventions]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9328</guid>
		<description><![CDATA[Discussing the creation of lightweight maps for mobile web apps.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9328&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>When it comes to building interactive maps for desktop web, most of us are quite comfortable using APIs like Google Maps or Bing Maps. But when we need to port or build something for mobile, it often feels like we&#8217;re crumpling a clean sheet of paper into a paper ball. Certainly, dealing with a smaller screen size, slower processor, and less memory can feel like a frustrating step backwards. But if you consider that mobile devices have touch screens, cameras, microphones, accelerometers, wireless and GPS capabilities on top of being portable, mobile devices are in a way better place than desktop PCs. So if we take the time to understand their limitations and features, we can build lightweight applications that are more like origami — compact, elegant, and functional — instead of like a crumpled paper ball that you&#8217;re ready to throw in the trash can.</p>
<table style="border:1px solid #DDD;border-radius:10px;">
<tbody>
<tr>
<td style="padding:10px;text-align:center;font-weight:bold;">Desktop web development is like this&#8230;</td>
<td style="padding:10px;text-align:center;font-weight:bold;">Mobile web can feel like this&#8230;</td>
<td style="padding:10px;text-align:center;font-weight:bold;">But mobile should and can be like this&#8230;</td>
</tr>
<tr>
<td style="padding:10px;text-align:center;"><a href="http://rimdevblog.files.wordpress.com/2012/05/sheet_sm.png"><img class="aligncenter size-full wp-image-9341" title="sheet_sm" src="http://rimdevblog.files.wordpress.com/2012/05/sheet_sm.png?w=140&#038;h=151" alt="" width="140" height="151" /></a></td>
<td style="padding:10px;text-align:center;"><a href="http://rimdevblog.files.wordpress.com/2012/05/crumpled_sm.png"><img class="aligncenter size-full wp-image-9342" title="crumpled_sm" src="http://rimdevblog.files.wordpress.com/2012/05/crumpled_sm.png?w=90&#038;h=90" alt="" width="90" height="90" /></a></td>
<td style="padding:10px;text-align:center;"><a href="http://rimdevblog.files.wordpress.com/2012/05/origami_sm.png"><img class="aligncenter size-full wp-image-9343" title="origami_sm" src="http://rimdevblog.files.wordpress.com/2012/05/origami_sm.png?w=140&#038;h=80" alt="" width="140" height="80" /></a></td>
</tr>
<tr>
<td style="padding:10px;text-align:center;">fairly standard</td>
<td style="padding:10px;text-align:center;">frustrating</td>
<td style="padding:10px;text-align:center;">compact, elegant, and functional</td>
</tr>
</tbody>
</table>
<p><span id="more-9328"></span></p>
<p>So where do we start? Well, when it comes to mobile web apps, file and transfer size matters — the smaller, the better. So the first thing I wanted to do was survey the landscape and compare the size of some of the different APIs that are available. (If I missed some that are lightweight, please let me know.) Although <a href="http://maps.google.com/" target="_blank">Google Maps</a> is the most popular API out there (and deservedly so), it&#8217;s JavaScript API and tile images are quite large. In my tests below, I created basic map pages for a 1024×768 screen using each of the APIs, and I found that Google Maps transfers about <span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">950 KB</span> of data! This can be a problem for smartphones since they have limited memory. Besides causing an application to crash, a memory-intensive app can also chew up precious kilobytes from a user&#8217;s data plan, and it can drain their battery faster than they want. Thankfully, we have some choices&#8230;</p>
<table style="border:1px solid #DDD;border-radius:10px;">
<tbody>
<tr style="background-color:#000;color:#fff;">
<td style="padding:10px;text-align:center;">API Provider</td>
<td style="padding:10px;text-align:center;">Requests</td>
<td style="padding:10px;text-align:center;">Transferred<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Images<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Scripts<br />
(KB)</td>
</tr>
<tr>
<td style="padding:10px;"><a href="http://msdn.microsoft.com/en-us/library/bb429619.aspx" target="_blank">Bing 6.3</a></td>
<td style="padding:10px;">43</td>
<td style="padding:10px;">596.07</td>
<td style="padding:10px;">358.06 (35)</td>
<td style="padding:10px;">228.92 (4)</td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;"><a href="http://msdn.microsoft.com/en-us/library/ff710049.aspx" target="_blank">Bing 6.3c (Core)</a></td>
<td style="padding:10px;">43</td>
<td style="padding:10px;">423.53</td>
<td style="padding:10px;">371.28 (34)</td>
<td style="padding:10px;">46.72 (5)</td>
</tr>
<tr>
<td style="padding:10px;"><a href="http://msdn.microsoft.com/en-us/library/gg427610.aspx" target="_blank">Bing 7.0</a></td>
<td style="padding:10px;">40</td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">431.45</span></td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">339.49 (30)</span></td>
<td style="padding:10px;">86.67 (6)</td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;"><a href="https://developers.google.com/maps/documentation/javascript/tutorial" target="_blank">Google v3</a></td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">66</span></td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">949.65</span></td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">842.93 (54)</span></td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">105.88 (12)</span></td>
</tr>
<tr>
<td style="padding:10px;"><a href="http://leaflet.cloudmade.com/reference.html" target="_blank">Leaflet 0.3.1 (Cloudmade)</a></td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">30</span></td>
<td style="padding:10px;">603.23</td>
<td style="padding:10px;">513.56 (26)</td>
<td style="padding:10px;">81.52 (1)</td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;"><a href="http://developer.mapquest.com/web/documentation/sdk/javascript/v7.0" target="_blank">MapQuest 7.0</a></td>
<td style="padding:10px;">60</td>
<td style="padding:10px;">900.30</td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">851.82 (53)</span></td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">46.81 (4)</span></td>
</tr>
<tr>
<td style="padding:10px;"><a href="https://github.com/stamen/modestmaps-js/wiki" target="_blank">Modest Maps 1.0.0 beta (MapBox)</a></td>
<td style="padding:10px;">38</td>
<td style="padding:10px;">901.48</td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">859.96 (35)</span></td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">39.62 (1)</span></td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;"><a href="http://api.maps.ovi.com/devguide/overview.html" target="_blank">Nokia Ovi</a></td>
<td style="padding:10px;">48</td>
<td style="padding:10px;">523.87</td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">372.47 (36)</span></td>
<td style="padding:10px;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">150.16 (10)</span></td>
</tr>
<tr>
<td style="padding:10px;"><a href="http://docs.openlayers.org/" target="_blank">OpenLayers 2.11 Mobile</a></td>
<td style="padding:10px;">52</td>
<td style="padding:10px;">595.28</td>
<td style="padding:10px;">508.70 (48)</td>
<td style="padding:10px;">83.35 (1)</td>
</tr>
<tr>
<td style="padding:10px;font-size:8pt;" colspan="5">* Note:</p>
<ul>
<li>These pages were tested at 1024×768.</li>
<li>The KBs for documents and stylesheets were excluded.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<h2>Bing</h2>
<p>As we can see from the results, Microsoft&#8217;s <a href="http://www.bing.com/maps/" target="_blank">Bing Maps</a> is a good alternative that has improved a lot since version 6.3. In version 6.3, Bing quietly introduced a &#8220;core&#8221; version for mobile that stripped out features like drawing lines and polygons. This reduced their JavaScript library from 230 KB to 47 KB! Unfortunately, if you needed some of those features, you were out of luck. But in version 7.0, they cleaned up their API and reduced it to 87 KB (without stripping features). So when you combine that savings with Bing&#8217;s smaller tile size, the Bing test map transferred <span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">432 KB</span> — that&#8217;s less than half of Google Maps! So I could stop here and just tell you to use Bing instead, but (as you&#8217;ll see) it&#8217;s always good to look at other options&#8230;</p>
<h2>Modest Maps</h2>
<p>Especially if we look at the API with the smallest library, <a href="http://modestmaps.com/" target="_blank">Modest Maps</a>, is a new library that weighs in at only <span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">40 KB</span>! It was designed to be simple, extensible, and it even works in older browsers like IE7. However, it&#8217;s tile size was the largest at <span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">861 KB</span>!</p>
<h2>MapQuest</h2>
<p><a href="http://www.mapquest.com/" target="_blank">MapQuest</a> is a provider that has been around for a while. Their version 7.0 is the second-smallest library at only <span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">47 KB</span>, but their tile size is the third largest at <span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">852 KB</span>.</p>
<h2>Nokia Ovi</h2>
<p>So if we&#8217;re also looking for an API that has the smallest tile size, Bing looks like the best choice. <a href="http://maps.nokia.com/" target="_blank">Nokia&#8217;s Ovi</a> tiles are also lightweight at <span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">373 KB</span>, but their JavaScript library is the largest at <span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">151 KB</span>! It&#8217;s too bad we couldn&#8217;t use Modest Map&#8217;s compact library with Bing&#8217;s lightweight tiles&#8230;or can we? Well, in a way we can&#8230;</p>
<h2>OpenLayers</h2>
<p><a href="http://openlayers.org/" target="_blank">OpenLayers</a>, as the name suggests, is a completely free and Open Source library that allows you to switch between different base layers like Google Maps, Virtual Earth (Bing), Yahoo, etc. From a business model, this approach makes a lot of sense because it means you&#8217;re not tied to one mapping provider and you&#8217;re not as restricted by licensing or forced-API changes. With this approach, you can switch providers without having to completely change your code.</p>
<p>However, OpenLayers supports other maps by creating their own API layer <strong>on top</strong> of the other mapping APIs. So to use OpenLayers with Google or Bing, you&#8217;d have to include their libraries as well! This approach is fine for desktop, but it doesn&#8217;t make sense for mobile. Also, OpenLayers is not as well-documented as some of the others, and its API can be harder to learn. But, if you&#8217;re doing some serious GIS work, this is an API you&#8217;ll want to consider.</p>
<h2>Leaflet</h2>
<p>Fortunately, a new lightweight library called <a href="http://leaflet.cloudmade.com/index.html" target="_blank">Leaflet</a> has been gaining popularity because it is a modern Open Source library that uses HTML5 and CSS3. It was designed from the ground up to work in modern and mobile browsers. Since CSS3 is hardware-accelerated on many mobile devices, visuals like zooming and fading will be much faster than JavaScript-based animations.</p>
<p>Also, Leaflet has an easy-to-use API. So just how easy is it to add a map? First, we include the CSS and JavaScript:</p>
<pre class="prettyprint">                <code class="language-html"> &lt;link rel="stylesheet" href="leaflet.css"&gt; &lt;script type="text/javascript" src="leaflet.js"&gt;&lt;/script&gt; </code></pre>
<p>Then we create a new tile layer specifying the format of the tile URL with some options like maximum zoom level:</p>
<pre class="prettyprint">                <code class="language-js"> var tileUrl = "http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png", tileAttr = "Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade", tileLayer = new L.TileLayer(tileUrl, { maxZoom: 18, attribution: tileAttr }); </code></pre>
<p>Then we create the map and add the tile layer to it:</p>
<pre class="prettyprint">                <code class="language-js"> var map = new L.Map("map", { center: new L.LatLng(43.6425778753, -79.3870621920), // Toronto zoom: 14 }); map.addLayer(tileLayer); </code></pre>
<p>That&#8217;s it! Like OpenLayers, Leaflet allows you to easily switch between tile providers, but it does this in a much cleaner way — all you have to do is change the tile URL. So you don&#8217;t even need to include a vendor&#8217;s API to use their tiles. Of course, if you do use another tile provider, make sure you contact them about licensing and include the proper attribution.</p>
<pre class="prettyprint">                <code class="language-js"> var tileUrl = "http://{s}.googleapis.com/vt?lyrs=m@174225136&amp;src=apiv3&amp;hl=en-US&amp;x={x}&amp;y={y}&amp;z={z}&amp;s=Galile&amp;style=api%7Csmartmaps", tileAttr = "Map data © 2012 Google", tileLayer = new L.TileLayer(tileUrl, { maxZoom: 22, subdomains: ['mt0', 'mt1'], attribution: tileAttr }); </code></pre>
<p>So with this simple approach, you can change the base tile layer to almost any provider as long as they are using OpenStreetMap&#8217;s <a href="http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames" target="_blank">&#8220;Slippy&#8221;</a> tile naming convention, which is pretty much every provider, except for Bing because Microsoft uses a different <a href="http://msdn.microsoft.com/en-us/library/bb259689.aspx" target="_blank">&#8220;Quadkey&#8221;</a> convention.</p>
<h2>Tile Naming Conventions</h2>
<p>Basically, Slippy uses a straight-forward naming convention that looks like this (&#8220;mustache-style&#8221; URL template):</p>
<pre>http://<span style="background-color:#ff0;">{s}</span>.tile.cloudmade.com/YOUR-API-KEY/997/256/<span style="background-color:#ff0;">{z}</span>/<span style="background-color:#ff0;">{x}</span>/<span style="background-color:#ff0;">{y}</span>.png</pre>
<p>where,</p>
<ul>
<li>{s} = subdomain</li>
<li>{x} = x-coordinate</li>
<li>{y} = y-coordinate</li>
<li>{z} = zoom level</li>
</ul>
<p>Here&#8217;s an example of an actual tile (near the CN Tower):</p>
<pre>http://<span style="background-color:#ff0;">b</span>.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/<span style="background-color:#ff0;">14</span>/<span style="background-color:#ff0;">4578</span>/<span style="background-color:#ff0;">5980</span>.png</pre>
<p>But if we compare Slippy to the Quadkey format, you&#8217;ll notice it&#8217;s different enough that we can&#8217;t easily use it (at least not with Leaflet — we can with Modest Maps):</p>
<pre>http://ecn.<span style="background-color:#ff0;">{s}</span>.tiles.virtualearth.net/tiles/<span style="background-color:#ff0;">{style}</span><span style="background-color:#ff0;">{quadkey}</span>?g=914&amp;mkt=en-us&amp;lbl=l1&amp;stl=h&amp;shading=hill&amp;n=z

http://ecn.<span style="background-color:#ff0;">t0</span>.tiles.virtualearth.net/tiles/<span style="background-color:#ff0;">r</span><span style="background-color:#ff0;">03022313122210</span>?g=914&amp;mkt=en-us&amp;lbl=l1&amp;stl=h&amp;shading=hill&amp;n=z</pre>
<p>because the Quadkey format works like this:</p>
<ul>
<li>At zoom level 1 (of the entire world), there are only 4 tiles (or quadrants) numbered from 0 to 3. At the next zoom level, each tile is sub-divided into &#8220;quads&#8221;, and so on.</li>
<li>So the length of the quadkey represents the number of zoom levels.</li>
<li>The quadkey of any tile starts with the quadkey of its parent tile.</li>
<li>The first letter (which is not really part of the quadkey) specifies the base map style (r = Road, a = Aerial (Satellite), h = Hybrid (Aerial + Labels)</li>
</ul>
<p><a href="http://rimdevblog.files.wordpress.com/2012/05/ic962381.jpg"><img class="aligncenter size-full wp-image-9345" title="IC96238" src="http://rimdevblog.files.wordpress.com/2012/05/ic962381.jpg?w=623&#038;h=365" alt="TITLE_IMAGE" width="623" height="365" /></a></p>
<figure>
<figcaption><a href="http://msdn.microsoft.com/en-us/library/bb259689.aspx" target="_blank">&#8220;Bing Maps Tile System&#8221;</a></figcaption>
</figure>
<p>Although it might be tempting to complain about Microsoft being different, from a database perspective, quadkeys makes indexing and storage really efficient.</p>
<h2>Hybrid Approach</h2>
<p>Hopefully, that gives you a better understanding of tile structures. Do you see the possibilities? This is AWESOME! This means we can easily interchange libraries and tiles to suit our needs. Essentially, we can build our own &#8220;hybrid&#8221; API or &#8220;mashup&#8221; from the best pieces available. So now we can have an API that uses Bing&#8217;s tiles, but is even <strong>lighter</strong> than Bing itself (which was already light to begin with at 432 KB)!</p>
<p>Here are some other combinations that are under 450 KB that you may want to consider:</p>
<table style="border:1px solid #DDD;border-radius:10px;">
<tbody>
<tr style="background-color:#000;color:#fff;">
<td style="padding:10px;text-align:center;">API Provider</td>
<td style="padding:10px;text-align:center;">Requests</td>
<td style="padding:10px;text-align:center;">Transferred<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Images<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Scripts<br />
(KB)</td>
</tr>
<tr>
<td style="padding:10px;">Modest Maps 1.0.0 beta + Bing Tiles</td>
<td style="padding:10px;">38</td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">380.51</span></td>
<td style="padding:10px;">338.97 (35)</td>
<td style="padding:10px;">39.62 (1)</td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;">Modest Maps 1.0.0 beta + Nokia Tiles</td>
<td style="padding:10px;">38</td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">412.41</span></td>
<td style="padding:10px;">370.93 (35)</td>
<td style="padding:10px;">39.62 (1)</td>
</tr>
<tr>
<td style="padding:10px;">Leaflet 0.3.1 + Nokia Tiles</td>
<td style="padding:10px;">30</td>
<td style="padding:10px;"><span style="background-color:#468847;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">431.78</span></td>
<td style="padding:10px;">342.09 (26)</td>
<td style="padding:10px;">81.52 (1)</td>
</tr>
</tbody>
</table>
<p>Since we were able to make Bing lighter, I was curious to see if we could do the same with Google, and the result really surprised me! As you may recall, Google Maps transferred <strong>950 KB</strong>, but when I combined Leaflet with Google&#8217;s tiles, it only transferred <strong>498 KB</strong>! That&#8217;s half the size, which is great! But why such a difference?! Well, if we look at the number of requests, it gives us a big clue — Google&#8217;s API is loading <strong>twice</strong> the number of tiles!</p>
<table style="border:1px solid #DDD;border-radius:10px;">
<tbody>
<tr style="background-color:#000;color:#fff;">
<td style="padding:10px;text-align:center;">API Provider</td>
<td style="padding:10px;text-align:center;">Requests</td>
<td style="padding:10px;text-align:center;">Transferred<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Images<br />
(KB)</td>
<td style="padding:10px;text-align:center;">Scripts<br />
(KB)</td>
</tr>
<tr>
<td style="padding:10px;">Google v3</td>
<td style="padding:10px;">66</td>
<td style="padding:10px;">949.65</td>
<td style="padding:10px;">842.93 (54)</td>
<td style="padding:10px;">105.88 (12)</td>
</tr>
<tr style="background-color:#eee;">
<td style="padding:10px;">Leaflet 0.3.1 + Google Tiles</td>
<td style="padding:10px;">30</td>
<td style="padding:10px;">497.71</td>
<td style="padding:10px;">408.01 (26)</td>
<td style="padding:10px;">81.52 (1)</td>
</tr>
<tr>
<td style="padding:10px;"><strong>Difference:</strong></td>
<td style="border-top:2px solid #000;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">36</span></td>
<td style="border-top:2px solid #000;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">451.94</span></td>
<td style="border-top:2px solid #000;"><span style="background-color:#b94a48;color:#fff;font-weight:bold;padding-left:10px;padding-right:10px;border-radius:15px;">434.92</span></td>
<td style="border-top:2px solid #000;">24.36</td>
</tr>
</tbody>
</table>
<p>At first, I thought it might be pre-fetching or &#8220;lazy loading&#8221; tiles for areas outside the bounding box in case a user pans or zooms. But when I inspected the extra tiles, I found it&#8217;s actually loading another set of tiles for the <strong>same area</strong>, which I haven&#8217;t been able to figure out why — the extra tiles don&#8217;t seem to be displayed anywhere. It&#8217;s still a map view tile, but it has slightly different labels. Notice the one on the right has &#8220;Corktown&#8221; and the other one doesn&#8217;t?</p>
<table style="border:1px solid #DDD;border-radius:10px;">
<tbody>
<tr>
<td style="padding:10px;text-align:center;font-weight:bold;">Tile Set 1 (displayed)</td>
<td style="padding:10px;text-align:center;font-weight:bold;">Tile Set 2 (not displayed)</td>
</tr>
<tr>
<td style="padding:10px;font-size:8pt;"><span style="background-color:#ff0;"><a href="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner1_circle.png"><img class="aligncenter size-full wp-image-9347" title="vt_dvp_gardiner1_circle" src="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner1_circle.png?w=256&#038;h=256" alt="" width="256" height="256" /></a>m@174232040</span>&amp;src=apiv3&amp;hl=en-US&amp;x=4580&amp;y=5979</p>
<p>&amp;z=14</p>
<p>&amp;s=Galileo</p>
<p>&amp;style=api%7Csmartmaps</td>
<td style="padding:10px;font-size:8pt;"><span style="background-color:#ff0;"><a href="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner2_circle.png"><img class="aligncenter size-full wp-image-9348" title="vt_dvp_gardiner2_circle" src="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner2_circle.png?w=256&#038;h=256" alt="" width="256" height="256" /></a>m@174000000</span>&amp;src=apiv3&amp;hl=en-US&amp;x=4580&amp;y=5979</p>
<p>&amp;z=14</p>
<p>&amp;s=Galileo</p>
<p>&amp;style=api%7Csmartmaps</td>
</tr>
</tbody>
</table>
<p>I&#8217;m sure there&#8217;s a good reason for this, but I&#8217;d be curious if there&#8217;s an option to disable that? Either way, the good news is Google&#8217;s tiles are not as heavy as I first thought so we can use them with Modest Maps or Leaflet to build familiar-looking mapping applications that will be more lightweight especially for mobile.</p>
<p>Besides being able to switch between providers, this hybrid approach has other advantages:</p>
<ol>
<li>For packaged applications like <a href="https://bdsc.webapps.blackberry.com/html5/" target="_blank">BlackBerry® WebWorks™</a>, you can locally include the required API files (JavaScript, CSS, and images) with your application so you don&#8217;t need to fetch them from a remote server. This makes loading an app faster and reduces bandwidth charges.</li>
<li>Another advantage of having local files is you don&#8217;t have to worry as much about a provider forcing an API change that can break your customizations. Although, you can usually reference an older API, sometimes a provider will force an upgrade even if you try to reference an older version.</li>
<li>In the case of Yahoo! Maps, which discontinued its map service in September 2011, a local version means your app can still work. For example, Leaflet provides a layer control so you can select from different base layers.</li>
</ol>
<p>These advantages are important especially for enterprise or mission-critical applications that need to minimize risk and downtime. So in the next post, I&#8217;ll cover some techniques for adding offline capabilities to your map. Hopefully, with this &#8220;best of breed&#8221; approach, you&#8217;ll be ready to build a map-based app that will feel more like a paper airplane than a paper ball.</p>
<div style="text-align:center;"><a href="http://rimdevblog.files.wordpress.com/2012/05/origami_sm1.png"><img class="aligncenter size-full wp-image-9349" title="origami_sm" src="http://rimdevblog.files.wordpress.com/2012/05/origami_sm1.png?w=140&#038;h=80" alt="" width="140" height="80" /></a></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9328&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/05/lightweight-maps-for-mobile-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/01266d01d1ae9a95d889f5143acd2a49?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">myjing</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/sheet_sm.png" medium="image">
			<media:title type="html">sheet_sm</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/crumpled_sm.png" medium="image">
			<media:title type="html">crumpled_sm</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/origami_sm.png" medium="image">
			<media:title type="html">origami_sm</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/ic962381.jpg" medium="image">
			<media:title type="html">IC96238</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner1_circle.png" medium="image">
			<media:title type="html">vt_dvp_gardiner1_circle</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/vt_dvp_gardiner2_circle.png" medium="image">
			<media:title type="html">vt_dvp_gardiner2_circle</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/origami_sm1.png" medium="image">
			<media:title type="html">origami_sm</media:title>
		</media:content>
	</item>
	</channel>
</rss>
