Skip to main content

Posts

Showing posts from October, 2011

Tessellating shapes on top of Bing Maps in a WP7 app

Before I complete the ' How many pins can Bing Maps handle in a WP7 app... ' set of posts . I want to take one last diversion and show how you can tessellate shapes on top of the Bing Maps control in a WP7 app. This builds on top of a previous post about drawing shapes on top of Bing Maps. If you're unsure what tessellation is, then the following definition should give you a good idea: A tessellation is created when a shape is repeated over and over again covering a plane without any gaps or overlaps. Only three regular polygons tessellate in the Euclidean plane: triangles, squares or hexagons. Shown below are some graphical examples of how these shapes tessellate: I'm only going to show how you can tessellate these shapes on top of the map control. The effect will be rendered as a set of MapPolygon class instances. You could achieve a similar effect with a set of MapPolyline class instances and it would be probably a lot easier but, and it is an imp

WP7Contrib: Added support for GZip compression to ResourceClient

With the release of Mango for WP7 and a user request for GZip compression support in the contrib I've added GZip compression support to the ResourceClient in WP7Contrib .This means you can now request GZip compression for HTTP requests against back end web servers when using the ResourceClient in the contrib. All you have to do is specify 'WithGZip' method in the setup: When you compare the debug statements in the output window of visual studio you can see the difference in HTTP response lengths, the first shows no compression and the second includes compression: As you can see the HTTP response length drops from 43273 (bytes) to 8927 (bytes), this is obviously great not only from a performance point of view of the app but also from the cost to user, we have managed to lower their data usage. This code is available in the GZipDemo app in the WP7Contrib Spikes directory (7.1).

WP7Contrib: URL shortening in a WP7 app

I needed the ability to shorten a URL for a WP7 app the other day so I could share a URL via the ShareLinkTask, more info about this task can be found on MSDN . What follows is a solution to shortening a URL programmtically using tinyurl.com . Obviously shortening a URL from a phone requires a connection, so this might not be applicable to a lot of apps. The problem is not the actual connection but the quality of said connection. When tethered or on WIFI the time required to shorten a URL is insignificant, but when on 3G the time is very noticable. The solution I came up with allowed me to be abstracted away from the under lying HTTP request, infact it allowed me to write the code in 3 lines of code! private void HandleShortenButtonClick ( object sender , RoutedEventArgs e ) { this . tinyUrlShortener . Shorten ( this . url . Text ) . ObserveOnDispatcher ( ) . Subscribe ( u = > this . shortenedUrl . Text = u ) ; } The implementation for in

Drawing shapes on top of Bing Maps in a WP7 app

Before I complete the ' How many pins can Bing Maps handle in a WP7 app... ' set of posts . I wanted to show how I'm drawing shapes on top of the Bing Maps control in WP7. This is based around using the MapPolygon class in the Microsoft.Phone.Controls.Maps namespace, more info on MSDN . Basically this will drawn lines betweens the geo-locations defined in the collection exposed by the Locations property. You're also able to define other properties such as fill colour, stroke thinkness, opacity. With these you have the ability to really customize any polygon you render over the map control. I'm going to show how I achieved the following screen shots and how this is all based around using the well known Haversine formula with only the centre location of the visible bounding rectangle of the Bing Maps control: A couple of things to note, UI design is not my forte (as @RichGee will tell you) so the following is more about how to achieve it than what it fin