I have a Silverlight application and in my MainPage.xaml, I have a Map which I named as “MyMap”. This is the logic of what I am going to do to get the current browser location.
- Find my Silverlight object in the browser and inside my Silverlight object, find “MyMap” and set it’s location and zoom level.
Here this is what happens.
- Check if Geolocation is supported.
- If supported, run the getCurrentPosition() method.
- If the getCurrentPosition() method is successful, it returns a coordinates object to the function specified in the parameter which is SetMapPosition.
- The SetMapPosition() function will get my silverlight object. Inside silverlight object, sets the properties to MyMap object which I have exposed to the browser from the code behind.
This is output. Since I am in Colombo, Sri Lanka, Map is zoomed to Colombo.