Free DNN Ajax LiveMaps MashUp Module

20. Apr 2007

This DNN module is available freely (BSD License) for download. You can download the source code and/or a Zip installation package to directly install it in DNN if you want to:

Download from our DNN Modules Page

DISCLAIMER: This module was built and tested with DNN 4.5.1

Gaia WhereAmI DNN Module

We've got a lot of positive feedback about our Free DNN Chat Module, and we intend to keep more DNN modules coming, just keep your eye on our website and blogs.

While we were brainstorming about a cool idea for a DNN Module, we were thinking about possibly using our LiveMaps Mashup Control and Jan came up with this cool idea (as usual) of creating an IP Geo-location module, to show the user of DNN on the LiveMap where he is.

How to Create the DNN LiveMaps Mashup Module


It's probably a good idea now to open the solution (Download From Here) and take a look around as we walk through this

First of all, as I mentioned before we are going to use our LiveMaps Mashup Control which is available as a sample on how to build your own Gaia controls. It is also included as a Class Library project in the downloadable source code for this module.

We also decided to use Hostip.info, which is a community-based project to geo-locate IP addresses and it's database is freely available. Communicating with Hostip.info is really easy. A simple HTTP request to this URL http://api.hostip.info/get_html.php with the following params ip=12.215.42.19 and position=true, you will get a response that looks like this:

Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588

Those lines are separated by \n character, so we created HostIP.cs which has two classes, "Location" which encapsulates a Location (Country, City, Lat. and Long.) and has two constructors, a constructor that just populates those fields with default values, and a constructor that takes the response we get from Hostip.info and through the magic of RegEx extracts the interesting parts that we need (Country, City, Lat., Long.) and populates the fields.

The other class we have here is the static class HostIP that has one static method that takes an IP as an argument, communicates with Hostip.info and returns a Location. And all we need to do now is to consume this class.

We called the module WhereAmI, and we have two ascx Web User Controls. WhereAmI.ascx that is our main UI for the module and Settings.ascx, which we use (or rather the admin of the DNN website uses) to setup some settings specific to our module. Both modules are localized, so you can add extra local resource files with different languages if you like to do so. WhereAmI.ascx has several labels that we will use to display the Country, City, Latitude and Longitude. It also has our LiveMaps control that will display the location.

The other control Settings.ascx, has a Gaia RadioButtonList to allow the admin to choose the mode that this module will run in. Either, RemoteClientIP to use the IP of the remote client (the DNN website user), or HardcodedIP to provide an IP that will be used all the time. It also has a Gaia TextBox to provide that IP, and a RegularExpressionValidator control to make sure it's a correct IP, the error message for this validator is provided through the Local Resource File (as well as all text in both modules) so you can easily localize the module.

In code view for this control (WhereAmI.ascx.cs), you can see that we inherited from DNN's PortalModuleBase, we also have two properties to get the Mode and the HardCodedIP from settings. And in Page_Load event handler, we basically check the Mode and accordingly use either the provided (HardCoded) IP or the IP of the Remote Client, to query HostIP for a location. After getting the populated Location, we populate the labels with their appropriate data (Country, City, Latitude and Longitude) and also set the Latitude, Longitude and Zoom properties of the LiveMap Control. To display the location.

See how easy that was, as easy as saying Gaia :)

This module is released under the BSD license and you can do whatever you like with it, just go nuts ;)

Note: Due to some incompatibilities between LiveMaps and Firefox this module currently works only in Internet Explorer

Please, if you like this module, help us to spread the word by Digging this post

AddThis Social Bookmark Button Add to DZone AddThis Feed Button


Tags: asp.net gaia dnn web ajax
Comments
RE: Free DNN Ajax LiveMaps MashUp Module
Posted 24. Apr 2007 by thomas
Note that all of our DNN modules will if you link to the GPL version of Gaia now be GPL licensed dut to incompatibilities between BSD and GPL. If you want to have a "closed source" version of any of our DNN modules you can however aquire a Gaia Commercial License from which you'll have the rights to use them as you wish! This does NOT constrain you from USING them for free however!
RE: Free DNN Ajax LiveMaps MashUp Module
Posted 26. Apr 2007 by elmaynard...gmail,com
Just curious who on the team is in St Clairsville? I'm about 1.5 hours north of there. -e
RE: Free DNN Ajax LiveMaps MashUp Module
Posted 26. May 2007 by anonymous
I try this comment

 
Legal note: the meaning and content expressed on these blogs don't necassary correspond with the meaning of the legal company Gaiaware AS, but are considered to be personal opinions and expressions.