<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


HOW TO find the latitude & longitude of any town/city using Virtual Earth Map Control 6

ko aham kuta aayaatah (Who am I? From where do I come?) - Adi Shankaracharya

Geography was my favorite subject in school. So more than a year ago when I heard of the MS Virtual Earth mapping service, I monkeyed around with it & put up a quick & dirty fun app to search for any given place in India & show it's latitude and longitude.

The interesting thing about the Virtual Earth mapping service is the low barrier of entry for developers. It works with just plain HTML & client-side Javascript. As such it can be hosted on any web server & used along with any server-side language. Unlike Google Maps which works works only for a real domain, Microsoft's Virtual Earth Map Control works locally and does not require signing up for an API key.

I was amazed recently to find that there have been more than 3 versions of the Virtual Earth Map Control since I last tried it out. The latest version Virtual Earth Map Control 6 contains a host of fantastic features. The Javascript classes & related members of the Map Control are comprehensively documented in the MSDN Help with simple & practical examples.

My biggest & most pleasant surprise was that there is now a ready made method to get the latitude, longitude pair for the point you clicked on the map irrespective of the zoom factor. With a few minor changes to the MSDN code sample for the PixelToLatLong Method, I now have a sample that gets you the latitude and longitude of any Indian town/city (that just as well works for any place in the world)

Related links:
Reverse geocoding
Winforms Earth v4

Labels: , ,

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment