Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • map is contentiously refresh

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 563
    Answer it

    here is my java script code

    function onSuccess(position)  {
                var element = document.getElementById('map');
                var lat=position.coords.latitude;
                var lang=position.coords.longitude;
                var myLatlng = new google.maps.LatLng(lat,lang);
                var mapOptions = {zoom: 10,center: myLatlng};
                var map = new google.maps.Map(document.getElementById('map'), mapOptions);
                var marker = new google.maps.Marker({position: myLatlng,map: map});
                map.setCenter(myLatlng);
                }
                function onError(error) {
                alert('code: ' + error.code + '\n' +
                'message: ' + error.message + '\n');
                }
                var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 3000 });
    
       google.maps.event.addDomListener(window, 'load', onSuccess);
    

 1 Answer(s)

  • Hi,
    In your code you have used watchposition with timeout 3000 milliseconds due to this your onSuccess Function is calling every three seconds and map is refreshing repeatedly.

    Hope this will help you... :)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: