Click here to Skip to main content
14,640,678 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi i create simple web application project to display location from database on Google API map , the question is how can i use this application offline ?
i need to download or using Google map offline ?
this is my code :)

ASPX code
<script type="text/javascript">
    function initialize() {
        var markers = JSON.parse('<%=ConvertDataTabletoString() %>');
        var mapOptions = {
            center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
            zoom: 5,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
              marker:true
        };
        var infoWindow = new google.maps.InfoWindow();
        var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        for (i = 0; i < markers.length; i++) {

            var data = markers[i]

            var myLatlng = new google.maps.LatLng(data.lat, data.lng);

            var marker = new google.maps.Marker({

                position: myLatlng,

                map: map,

                title: data.title

            });

            (function(marker, data) {



                // Attaching a click event to the current marker

                google.maps.event.addListener(marker, "click", function(e) {

                    infoWindow.setContent(data.description);

                    infoWindow.open(map, marker);

                });

            })(marker, data);

        }

    }

</script>
</head>
<body onload="initialize()">





code behind :
protected void Page_Load(object sender, EventArgs e)
{
ConvertDataTabletoString();
}

public string ConvertDataTabletoString()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection("Data Source=x;Initial Catalog=googleDB;Integrated Security=true"))
{
using (SqlCommand cmd = new SqlCommand("select title=City,lat=latitude,lng=longitude,description from tbl_Locations", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<dictionary><string,>> rows = new List<dictionary><string,>>();
Dictionary<string,> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string,>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);

}
rows.Add(row);
}
return serializer.Serialize(rows);
}
}
}
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Couldn't you have just typed "use google maps offline[^]" and looked through your options?
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100