1

I added a google Map in asp.net application. But running the application, sometimes the Map displayed and sometimes too it doesn't display. I can't find the problem causing that malfunctioning of the application.

Here is the source code :

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>

   <script type="text/javascript">
    var markers = [
    <asp:Repeater ID="rptMarkers" runat="server">
    <ItemTemplate>
                {
                    "Network": '<%# Eval("Network") %>',
                    "lat": '<%# Eval("GPSLat") %>',
                    "lng": '<%# Eval("GPSLong") %>',
                    "Localite": '<%# Eval("Localite") %>'

                }
 </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: 10,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
        };

        var infoWindow = new google.maps.InfoWindow();

        var map = new google.maps.Map(document.getElementById("dvMap"), 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.Network 
            });
            (function (marker, data) {
                google.maps.event.addListener(marker, "click", function (e) {
                    infoWindow.setContent('<b>Reseau:</b> ' + data.Network + '<br/> <b>Localite:</b>' + data.Localite);
                    infoWindow.open(map, marker);
                });
            })(marker, data);
        }
    }
</script>

This is the method that bind the repeater from from the web service method:

MediaWayBackEndService.BMBackEndServiceClient backEndService = new MediaWayBackEndService.BMBackEndServiceClient("BasicHttpBinding_IBMBackEndService");
            rptMarkers.DataSource = backEndService.GetKilometricNetwork(network, value).Tables[0];
            rptMarkers.DataBind();

This is the output of the application when it works fine and when it does not work fine.

enter image description here

enter image description here

Localhost liks cant be opend from other users!

Based on the console, i have found 1 errors:

Google Maps API warning: SensorNotRequired: https://developers.google.com/maps/documentation/javascript/error-messages
7
  • Do you have any errors in your browser console? Commented Nov 27, 2015 at 13:51
  • Try to isolate the problem to either the browser, your ASP application, or the service you're calling. Save the page to see if it works when you open it, and test your service independently (may want to try Fidler or Postman to monitor and mimic requests) Commented Nov 27, 2015 at 14:05
  • @aardila i updated the post to show the result. Commented Nov 27, 2015 at 14:14
  • @nimeshjm i updated the post to show the result. In the tow cases i have the set of data in the first tab, meaning that the webservice return the data Commented Nov 27, 2015 at 14:15
  • Can you open developer tools in your browser (F12) and look in the "console" tab and check if there are any errors? Commented Nov 27, 2015 at 14:16

1 Answer 1

1

you could try displaying it whitout script. i used an iframe with variable strings.

ifmaps.Src = "https://maps.google.de/maps?hl=de&q=" + sStreet + " " + sCity + "+(" + sCity + ")&ie=UTF8&t=&z=17&iwloc=B&output=embed";

<div>
        <iframe width="600" height="300" runat="server" ID="ifmaps" frameborder="10" scrolling="no" marginheight="0" marginwidth="0" > </iframe>
</div>
Sign up to request clarification or add additional context in comments.

4 Comments

please can you give more details on the variables used in your case. i called the goodle Map using a div id 'dvMap' . <div id="dvMap" style="width: 1100px; height: 550px"></div>
sStreet , sCity, sCity you fill them with the wanted location. sry didnt see it its german ;)
ok, please can u give more details on implementation of this in asp.net
in my case i load Long & lat from data source and use gmap to display them. but in case i dont see how you pass the long & lat values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.