Hands-On AddIn Workshop Dynamics NAV 2013: Creating a Bing Map AddIn with server side geocoding

Preface

Recently I had the honor to give a Hands On workshop on Client Extensibility for Dynamics NAV 2013 at the Airlift event in Leipzig / Germany.

I thought I create a new workshop with a new AddIn - A Bing Map showing a customer on a map, including Geocoding. The presentation and workshop files are available for download here:

 

The Workshop

In order to go through the workshop you need to have

  1. Dynamics NAV 2013 installed 
  2. your Developer License loaded into the NAV system
  3. Visual Studio 2012 Professional installed
  4. my Visual Studio Templates for NAV 2013 installed 
  5. the AddIn Registration toolkit for NAV 2013 added to your data base and the assembly placed in the Client AddIns directory
  6. the Bing Map Control SDK installed

 You will also need to request your self a developer key in order to use the Bing Map API, which you can do starting from the Bing Maps Developer Portal.

 

The Workshop is build in 6 steps (please excuse some German terms in the slides below):

  1. It starts with creating a basic AddIn using the Visual Studio templates and adds the Map WPF control and shows a Map part in the Windows Client.
     

  2. Then it adds server side controlled authentication, in order to set the Bing Map Key. This is done using a custom interface method.
      

  3. This step adds the capability to position the map, zoom in and out problematically and control the view. In this step a serializable .Net object is introduces that is passed for the location as a parameter
     

  4. Now we add a layer for pushpins and set a pushpin for a customer. We introduce client side geocoding here.
     

  5. In this step geocoding is moved server side and the position is requested first time a customer shall be located on a map. Th elocation is stored in the customer table.
     

  6. Finally we introduce the concept of asynchronous geocoding on the server. Such that the response of a geocoding request is not awaited and blocks the execution any longer. As soon as the asynchronous request returns, the customer location is updated in the database. The client is using the PingPong AddIn to poll for updates.

     

  7. The seventh steps is not included, but left for your own tinkering: Move the geocoding request into a code unit that is used in a Job Queue. This could allow automatic geocoding: for addresses where location is missing, but last geocoding did not return empty results or for addresses that have changed. With a job queue this can be then done behind the scenes, without involving the client.
    (And this is of course the only good way to do geo coding, yet for the purpose of experimentation in the workshop I have implemented it in different tiers.) 

 

How to just try out the final step:

  1. Copy all dlls from Workshop folder e.g. below for Step 6 in a subfolder (e.g BingMap) the Client AddIns directory :
    "\Workshop\Step 6 (Serverside Async Geocoding)\MyBingMapAddIn\BingMapAddIn\bin\Debug\*.dll" => 
    "C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Add-ins\BingMap\"
     

  2. Copy MyBingGeocoder.dll from Workshop folder e.g. below for Step 6 in a subfolder (e.g BingMap) the Server AddIns directory :
    "\Workshop\Step 6 (Serverside Async Geocoding)\MyBingMapAddIn\BingMapAddIn\bin\Debug\MyBingGeocoder.dll" =>
    "C:\Program Files\Microsoft Dynamics NAV\70\Service\Add-ins\BingMap\"
     

  3. Register AddIn. You may use the AddIn toolkit in the resources directory for that.
    Copy the AddInToolkit forlder into the Client AdIns folder:
    "\Workshop\Reources\AddInToolkit\" =>  "C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Add-ins\AddInToolkit\
    Run the page 65006 "Client Add-in registration" from the objects in the fob file "AddInRegistrationTool-V7.fob"
    Click on "Check AddIn Files" and wait until list is updated. Check then the "MyBingMapAddIn" in order to register it.
     

  4. Import / merge the objects from fob / text files:

    Part: "MyBingMapPart"
    Changes to table Customer. for Latitude,Longitude,IsGeoCoded,GeocodingFailed and trigger code to maintain those fields
    Customer list:utilize BingMapPart with sub page link
    optional: Customer card: show geolocation fields
     

  5. You may update the global Text constant "BingAppKey" in the "MyBingMapPart" with a key you have requested for yourself.
    (The key contained will be disabled soon.)
     

  6. Run the customer page and makew shure the BingMap part is showing. While scrolling through the list addresses will be geocoded and the
    selected customer shown on the map if address could be geocoded.
    When address changes, location will b ereset and new geocoding will be issued, as soon as customer selected again.
    Geocoding happens asynchronous. If geocoding is not possible maps zooms out to whole world.

 

I hope this workshop is somewhat helpful, inspiring, ...

And please keep enjoying to develop cool extensions for Dynamics NAV ! 

 

 Christian Abeln 
Senior Program Manager
Microsoft Dynamics NAV

Comments

  • Anonymous
    August 02, 2013
    The comment has been removed
  • Anonymous
    August 19, 2013
    Great stuff. Only thing i had to add was the geocoding.dll to the service add-in folder
  • Anonymous
    January 17, 2014
    The comment has been removed
  • Anonymous
    January 29, 2014
    Hi Christian,Thanks a lot for this, it save me many hours... :-) but now my customer are asking about creating addins for the Web Client, I have already created an addin with WPF, do you know if I can use that for the web client, do you have an example?thanks in advanceOscar