Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi everyone!

I am working on Google Maps and I have successfully displayed it in my web page. We have 24 hours of GPS recorded data. It contains longitude and latitud., Now as the data changes along with time, I have to populate a marker on Google Map on every different time stamp.

My Logic:

I have Taken a <big>DIV </big> to Display Google Map in it, Two Text Boxes For Longitude and latitude respectively. one Java Script To Load Google Map in Div Script is as Follows
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="util.js"></script>
    <script type="text/javascript">

        var directionsDisplay; 
        var directionsService = new google.maps.DirectionsService();
        function initialize() {
            directionsDisplay = new google.maps.DirectionsRenderer();
           // Retriving Values From Text Boxes
            var slong = document.getElementById('&lt;%= txtLong.ClientID %&gt;').value;
            var sLati = document.getElementById('&lt;%= txtLati.ClientID %&gt;').value;
            var slongSV = 0;

            var myLatlng = new google.maps.LatLng(slong, sLati);
            var myOptions = {
                zoom: 16,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            var marker = new google.maps.Marker
    ({
        position: new google.maps.LatLng(slong, sLati),
        map: map,
        title: 'Click me'
    });

So Above Code Work Fine :)

My Problem:

i have DIV in update Panel and i have taken a Timer in which ticks i m loading new Values in Text boxes BUT When Timer Ticks Update Panel Updates And Google Map Go invisible [ Reason no Default Values/ If Defaults Values Than it shows that Default Value].

Need Of Solution:

I want to display that Google Map without any flickers or Smooth like we have in Android phones Navigation app :P, and i should be able to set The coordinates from Server Side or Code Behind

Can Any one Help me on this Please
Posted
Updated 19-Apr-13 3:49am
v2

1 solution

Hi I have solved it by myself

the problem was i was loading the map in Div but due to timer
AsyncPostBackTrigger
my div was losing the data it was because my google variable was local and it was not killed after the function so i created global object of map and removed ajax Timer and used Java setTimeOut() and in other function i was updating the marker and coordinates
 
Share this answer
 
Comments
cev 4-Jun-14 6:24am    
coud you paste here your solution?. I have exactly the same problem. Thanks
JohnBrittoJ 14-Jul-14 7:59am    
Hi I have the same problem. Could you please give me a code snippet of yours that you have solved. So that I could resolve my issue???

Thanks

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900