Google Map Marker Possision not showing in marker Info Window

Last Reply 4 months ago By dharmendr

Posted 4 months ago

Hai I got a google map map marker code in your site,but in my code cant get information in marker possision at run time.i attached my code from here.Please check this

Thank You

 Dim dt As DataTable = Me.GetData("SELECT dbo.tblContainers.ContainerName as ContainerName , dbo.tblContainers.Logitude as Logitude, dbo.tblContainers.Latitude as Latitude,dbo.tblRentContractsDetails.CreatedOn as CreatedOn, dbo.tblRentContractsDetails.CreatedBy as CreatedBy, dbo.tblRentContractsDetails.LocationId as LocationId, dbo.tblRentContractsDetails.StartDate as StartDate, dbo.tblRentContractsDetails.EndDate as EndDate,dbo.tblEmployees.EmpName as EmpName FROM dbo.tblContainers INNER JOIN dbo.tblRentContractsDetails ON dbo.tblContainers.ContainerId = dbo.tblRentContractsDetails.ContainerId INNER JOIN dbo.tblEmployees ON dbo.tblRentContractsDetails.EmpId = dbo.tblEmployees.EmpId INNER JOIN dbo.tblContainerTypes ON dbo.tblContainers.TypeId = dbo.tblContainerTypes.TypeId WHERE dbo.tblContainers.TypeId =" & ddlTypes.SelectedValue)
            rptMarkers.DataSource = dt
            rptMarkers.DataBind()

 

 

 

<script type="text/javascript">
        var markers = [
    
        
        <asp:Repeater ID="rptMarkers" runat="server">
       
       <ItemTemplate>
                 {
                     
                                       
                     "ContainerName": '<%# Eval("ContainerName")%>',
                     "CreatedOn":'<%# Eval("CreatedOn")%>',
                     "CreatedBy":'<%# Eval("CreatedBy")%>',
                     "Location":'<%# Eval("LocationId")%>',
                     "StartDate":'<%# Eval("StartDate")%>',
                     "EndDate":'<%# Eval("EndDate")%>',
                     "EmpName":'<%# Eval("EmpName")%>',
                     "lat": '<%# Eval("Latitude")%>',
                     "lng": '<%# Eval("Logitude")%>',
                 
                 }
    </ItemTemplate>
    <SeparatorTemplate>
        ,
    </SeparatorTemplate>
    </asp:Repeater>
        ];
    </script>

 

<script type="text/javascript">
    window.onload = function () {
        var mapOptions = {
            center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
            zoom: 8,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        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) {
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent(data.description);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
        }
    }
</script>

 

Posted 4 months ago
AmArcade says:
infoWindow.setContent(data.description);

Your marker doesn't contain the name description. So What ever you want to show in the info window set those content for infoWindow like below.

(function (marker, data) {
   google.maps.event.addListener(marker, "click", function (e) {
       infoWindow.setContent(data.ContainerName + '<br />' + data.EmpName);
       infoWindow.open(map, marker);
   });
})(marker, data);

 

I agree, here is the link: http://e-iceblue.com/free-api