Click here to Skip to main content
15,867,568 members
Articles / Web Development / ASP.NET
Tip/Trick

Online Geocoder with interactive Map

Rate me:
Please Sign up or sign in to vote.
4.72/5 (10 votes)
29 Jun 2015CPOL3 min read 41.3K   13   10
Web app to find geographical coordinates and apply them to the Bing Map

Introduction

Geographic coordinates provide the unified way to identify any place on Earth. City streets could change their names and numbers, but the universal coordinate system, free of daily vanities and challenges of time, presents perpetual time-invariant values on a planetary level. Geographic coordinates system in general includes longitude, latitude and elevation (height), but the most used are the first and the second ones, namely longitude/latitude. They could be presented either in degrees:minutes:seconds (so-called DMS) format or decimal degrees (DD) format (used in the application).

Geographic coordinates could be obtained via global positioning system (GPS) devices, but this technique requires the physical presence at the point of interest. As an alternative, the geocoding software applications (or simply geocoder, or geo-locator) could be used to convert the postal addresses to the corresponding longitude/latitude pairs. Such geocoder has been built in conjunction with interactive online Map powered by Microsoft Bing™ technology, allowing different views, panorama and zooming; it is available online totally free at [1], serving both practical and didactic purposes (no registration is needed).

Usage

The usage is rather straightforward and intuitive: in order to obtain the longitude/latitude information and the map of the geographic point of interest, either in the US, or worldwide follow the steps described below:

  1. Open web browser and navigate it to the Geocoder
  2. Enter the postal address into the search box and click on the "Find" screen button. Note: places in the US could be identified just by their ZIP (postal) code
  3. Upon the completion of screen reload, which could take up to several seconds, you should be able to see the longitude/latitude of the point of interest and corresponding Bing map. You could select the preferred map view modes (road, aerial or bird’s eyes), adjust zoom level (from 1 to 19) and perform the panoramic function

Multilingual support

Online geocoder has multi-lingual capabilities, accepting search queries in many foreign languages: Spanish, German, Italian, French, Russian, Greek, etc. Below are sample test results, corresponding to the world landmarks, entered in a search query in the language of origin:

  • Metropolitan Museum, New York |  Lat: 40.779437/Lon: -73.963244
  • Grand Central Terminal, NY | Lat: 40.752726/Lon: -73.977229
  • Colosseo, Roma | Lat: 41.89021/Lon: 12.492231
  • Ακρόπολη Αθηνών | Lat: 37.971532 /Lon: 23.725749
  • Brandenburger Tor, Unter Der Linden | Lat: 52.516275 /Lon: 13.377704
  • Champs-Elysées, Paris | Lat: 48.869576/Lon: 2.30825
  • Eiffel Tour, Champs De Mars | Lat: 48.85837/Lon: 2.294481
  • Museo del Prado, Madrid | Lat: 40.413782/Lon: -3.692127
  • Cappella Sistina, Rome |  Lat: 41.902947/Longitude: 12.454484
  • Музей Эрмитаж, Санкт Петербург | Lat: 59.939832/Lon: 30.31456

Demo

The following screenshots demonstrate the usage of Multilingual Geocoder with interactive Bing Map (see Fig 1-4):

Image 1

Fig.1 Columbus Circle NY, Geo Coordinates (the distances from NY City are calculated from this point)

 

Image 2

Fig.2 Columbus Circle NY on the Bing Map, sample screenshot (Aerial view mode)

 

Image 3

Fig.3 Coordinates of the Brandenburg Gate, Berlin, Germany

 

Image 4

Fig.4 Brandenburg Gate on Bing Map (Bird's eye view mode)

Points of Interest

Calculation of the great-circle (orthodromic) distance between two geo-points on the Earth surface is the general GIS task. It can be acomplished by using Spherical Earth projection algorithm listed below [2]:

C#
/*****************************************************************************************
Module           :  GIS.cs
Description      :  Calculate distance between two geo-points on surface
*****************************************************************************************
Author           :  Alexander Bell
Copyright        :  2011-2015 Infosoft International Inc
*****************************************************************************************
DISCLAIMER       :  This Module is provided on AS IS basis without any warranty
*****************************************************************************************
TERMS OF USE     :  This module is copyrighted. Please keep the Copyright notice intact.
*****************************************************************************************/
using System;

namespace BusNY
{
    internal enum UnitSystem { SI = 0, US = 1 }
    
    internal static class GIS
    {
        #region internal: properties (read-only)
        internal static double EarthRadiusKm { get {return _radiusEarthKM;} }
        internal static double EarthRadiusMiles { get { return _radiusEarthMiles; } }
        internal static double m2km { get { return _m2km; } }
        internal static double Deg2rad { get { return _toRad; } }
        #endregion

        #region private: const
        private const double _radiusEarthMiles = 3959;
        private const double _radiusEarthKM = 6371;
        private const double _m2km = 1.60934;
        private const double _toRad = Math.PI / 180;
        #endregion

        #region public Method: Spherical Earth projection
        public static double DistanceSEP(double Lat1,
                                        double Lon1,
                                        double Lat2,
                                        double Lon2,
                                        UnitSystem UnitSys ){
            try
            {
                double _radLat1 = Lat1 * _toRad;
                double _radLat2 = Lat2 * _toRad;
                double _dLat = (_radLat2 - _radLat1);
                double _dLon = (Lon2 - Lon1) * _toRad;

                double _a = (_dLon) * Math.Cos((_radLat1 + _radLat2) / 2);

                // central angle, aka arc segment angular distance
                double _centralAngle = Math.Sqrt(_a * _a + _dLat * _dLat);

                // great-circle (orthodromic) distance on Earth between 2 points
                if (UnitSys == UnitSystem.SI) { return _radiusEarthKM * _centralAngle; }
                else { return _radiusEarthMiles * _centralAngle; }
            }
            catch { throw; }
        }
        #endregion
    }
}

References

  1. The Orthodromic Distance Between Two Geo-points

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
United States United States
Dr. Alexander Bell (aka DrABell), a seasoned full-stack Software (Win/Web/Mobile) and Data Engineer holds PhD in Electrical and Computer Engineering, authored 37 inventions and published 100+ technical articles and developed multiple award-winning apps (App Innovation Contests AIC 2012/2013 submissions) Alexander is currently focused on Microsoft Azure Cloud and .NET 6/8 development projects.

  1. HTML5/CSS3 graphic enhancement: buttons, inputs
  2. HTML5 Tables Formatting: Alternate Rows, Color Gradients, Shadows
  3. Azure web app: Engineering Calculator VOLTMATTER
  4. Azure: NYC real-time bus tracking app
  5. Quiz Engine powered by Azure cloud
  6. 'enRoute': Real-time NY City Bus Tracking Web App
  7. Advanced CSS3 Styling of HTML5 SELECT Element
  8. Aggregate Product function extends SQL
  9. YouTube™ API for ASP.NET

Comments and Discussions

 
QuestionWanted a webservice to reference. Pin
Member 1149819230-Jun-15 7:53
professionalMember 1149819230-Jun-15 7:53 
GeneralMy vote of 1 Pin
Sebastiaan Lubbers29-Jun-15 22:01
professionalSebastiaan Lubbers29-Jun-15 22:01 
GeneralBing Maps are FUBAR because the marker(s) disappear everytim... Pin
Clinton Gallagher6-Jun-11 14:37
professionalClinton Gallagher6-Jun-11 14:37 
Generalunique!! Pin
GPUToaster™30-May-11 1:54
GPUToaster™30-May-11 1:54 
GeneralRe: Thank you! Pin
DrABELL30-May-11 2:33
DrABELL30-May-11 2:33 
Generalcool,my 5 Pin
Monjurul Habib29-May-11 6:47
professionalMonjurul Habib29-May-11 6:47 
GeneralRe: Thanks a bunch! Pin
DrABELL29-May-11 7:04
DrABELL29-May-11 7:04 
GeneralNice one Alex. 5! Pin
thatraja27-May-11 16:52
professionalthatraja27-May-11 16:52 
GeneralRe: Many thanks! Pin
DrABELL28-May-11 1:28
DrABELL28-May-11 1:28 
Many thanks!
GeneralRe: ccccccccc Pin
thienthanit31-May-11 15:53
thienthanit31-May-11 15:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.