Email: Password:       Forgot Password 
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.

User Current Location on Google Map using GeoLocation API in Website

Viewed:  2739 
Posted On:  13/02/2015 22:20:14 
How we can know user current location on Google Map ? 


In this Article I am going to explain how we can get user's current location using Google Map.

Below are my aspx and script references:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <title>Get User Current Location using Google Map Geolocation API Service in
    <script type="text/javascript" src="">
    <script type="text/javascript" src="">
    <script type="text/javascript">
        if (navigator.geolocation) {
        } else {
        alert("There is Some Problem on your current browser to get Geo Location!");
        function success(position) {
            var lat = position.coords.latitude;
            var long = position.coords.longitude;
            var city = position.coords.locality;
            var LatLng = new google.maps.LatLng(lat, long);
            var mapOptions = {
                center: LatLng,
                zoom: 12,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            var map = new google.maps.Map(document.getElementById("MyMapLOC"), mapOptions);
            var marker = new google.maps.Marker({
                position: LatLng,
                title: "<div style = 'height:60px;width:200px'><b>Your location:</b><br />Latitude: "
                            + lat + +"<br />Longitude: " + long
            var getInfoWindow = new google.maps.InfoWindow({ content: "<b>Your Current Location</b><br/> Latitude:" +
                                    lat + "<br /> Longitude:" + long + "" });
  , marker);
    <form id="form1" runat="server">
    <div id="MyMapLOC" style="width: 550px; height: 470px">
Now run your application:


Image 1.

You can change display setting from right top corner options:


Image 2.


Image 3.


Image 4.

         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us