469,912 Members | 1,839 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,912 developers. It's quick & easy.

How to Draw a Route in Google Map using Asp.net and Sql server Database Values

I'm New Developer of Google Map Using ASP.Net...

I developing one Project Using ASP.Net,C#,SQL Server in Google Maps...My Problem is Database Values are Retrieved into the Map,but line is not Drawn between the Markers...

This is My Code for Retrieving Data from Database to GMap
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     var markers = [
  3.     <asp:Repeater ID="rptMarkers" runat="server">
  4.     <ItemTemplate>
  5.              {
  6.                 "lat": '<%# Eval("Latitude") %>',
  7.                 "lng": '<%# Eval("Longitude") %>',               
  8.             }
  9.     </ItemTemplate>
  10.     <SeparatorTemplate>
  11.         ,
  12.     </SeparatorTemplate>
  13.     </asp:Repeater>
  14.     ];
  15.     </script>
  16.     <script type="text/javascript">
  17.  
  18.         window.onload = function () {
  19.             var mapOptions = {
  20.                 center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
  21.                 zoom: 12,
  22.                 mapTypeId: google.maps.MapTypeId.ROADMAP
  23.             };
  24.             var infoWindow = new google.maps.InfoWindow();
  25.             var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
  26.  
  27.             for (i = 0; i < markers.length; i++) 
  28.             {
  29.                 var data = markers[i];
  30.  
  31.                 var myLatlng = new google.maps.LatLng(data.lat, data.lng);
  32.  
  33.                 var marker = new google.maps.Marker(
  34.                 {
  35.                     position: myLatlng,
  36.                     map: map
  37.                 });  
  38.  
  39.                 var myTrip = myLatlng;  alert(myTrip);  
  40.                 var polyline = new GPolyline([new GLatLng(myTrip),
  41.                                     new GLatLng( myTrip),
  42.                                     ],"#3333cc", 10);            
  43.              }
  44.  
  45.  
  46.         }
  47.     </script>
Can Any one Help me...
Apr 24 '13 #1
0 2717

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by imani_technology_spam | last post: by
1 post views Thread by BT Openworld | last post: by
2 posts views Thread by Barry | last post: by
2 posts views Thread by George G. | last post: by
2 posts views Thread by Recep TARAKÇI | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.