Bookmap App tutorial

I recently came across the Mappit API online. I love reading books and an opportunity to make an app related to books will not be missed.  The API helps you to search for books related to a location – feed it  latitude/longitude coordinates and you can find all the books that are linked to that place.

In this post I’ll show how I made it into a Windows Phone 8.1 RT app.

  • I get the user’s current location
  • I also ask the user to type in any location they want.
  • Then I convert them into lat and long co-ordinates that I send over to the web service to retrieve book results.


How to get the user’s current location

 Geolocator geolocator = new Geolocator();
 geolocator.DesiredAccuracyInMeters = 50;     
         Geoposition geoposition = await geolocator.GetGeopositionAsync(
         maximumAge: TimeSpan.FromMinutes(5),
         timeout: TimeSpan.FromSeconds(10));

         string latitude = geoposition.Coordinate.Latitude.ToString("0.00");
         string longitude = geoposition.Coordinate.Longitude.ToString("0.00");
catch (UnauthorizedAccessException)     
    // the app does not have the right capability or the location master switch is off         
    StatusTextBlock.Text = "location  is disabled in phone settings.";     

How I take the user’s typed in location(text) and convert it to lat/long co-ordinates

 string addressToGeocode =  searchtext.Text; //user typed this location

// Geocode the specified address,Return no more than 1 result.

MapLocationFinderResult result =
                await MapLocationFinder.FindLocationsAsync(

// If the query returns results, display the coordinates
// of the first result.
if (result.Status == MapLocationFinderStatus.Success)
      string latitude = result.Locations[0].Point.Position.Latitude.ToString();
      string longitude = result.Locations[0].Point.Position.Longitude.ToString();

How I took the co-ordinates and fed it to the API

I used the MVVM (Model- View- Viewmodel) pattern to design the app. In the viewmodel, I have an ObservableCollection that stores all the book objects that are being received from the web service. The web service takes in lat and long co-ordinates and gives a JSON response filled with the books, and it’s easy to parse it through thanks to the nuget package JSON.Net.

   public async Task loadData(string lat, string longi)
            BookList = new ObservableCollection<book>();
            HttpClient client = new HttpClient();

            string jsonString;
                string apiURL = "" + lat + "&lon=" + longi;
                jsonString = await client.GetStringAsync(new Uri(apiURL, UriKind.Absolute));
               ObservableCollection<book> bookList = JsonConvert.DeserializeObject<ObservableCollection<book>>(jsonString);
               BookList = bookList;
            catch (System.Net.Http.HttpRequestException)
                var messageDialog = new MessageDialog("No internet connection has been found.").ShowAsync();


This returns a list of books for us- depending on the user’s query 🙂

screen2Hope that helps!  The app can can downloaded from here. It’s not perfect yet, as I made it for a short hackathon. But hope to update it soon.

Cheers 🙂


5 thoughts on “Bookmap App tutorial

    • Thanks for sharing this, it is exactly the sort of use I had in mind when I built the API. There is a toponym-based api option coming soon so it will be possible to skip the geocoding step and send the place name directly to Mappit.

      Best regards, Alex

      Liked by 1 person

      • Dear Alex, the global book map is a great project and I must thank you for allowing us access with the API! 🙂 I’ll be sure to update it with the upcoming changes. Hope the project continues to grow and wish you all the best. – Fariha


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s