using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; /// <summary> /// Summary description for GPSLib /// </summary> public static class gmap { public static String PlotGPSPoints(DataTable tblPoints) { try { String Locations = ""; String sJScript = ""; int i = 0; foreach (DataRow r in tblPoints.Rows) { // bypass empty rows if (r["lat"].ToString().Trim().Length == 0) continue; string Latitude = r["long"].ToString(); string Longitude = r["lat"].ToString(); string name = r["Name"].ToString(); // create a line of JavaScript for marker on map for this record Locations += Environment.NewLine + @" path.push(new google.maps.LatLng(" + Latitude + ", " + Longitude + @")); var marker" + i.ToString() + @" = new google.maps.Marker({ position: new google.maps.LatLng(" + Latitude + ", " + Longitude + @"), title: 'Click to see' , map: map });"; i++; } // construct the final script sJScript = @"<script type='text/javascript'> var poly; var map; function initialize() { var cmloc = new google.maps.LatLng(22.5697, 88.3697); var myOptions = { zoom: 11, center: cmloc, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); var polyOptions = { strokeColor: 'blue', strokeOpacity: 0.0, strokeWeight: 0 } poly = new google.maps.Polyline(polyOptions); poly.setMap(map); var path = poly.getPath(); " + Locations + @" } </script>"; return sJScript; } catch (Exception ex) { throw ex; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)