locked
Google Marker not refresh RRS feed

  • Question

  • User229488726 posted

    i have a google map where marker data come from database when 1st time load the map in work fine but when i send new location from database  the map marker not working.

    maker show the previous location not the current location what i send from my code  

    how to solve the problem please help me this is my function

    function loadmap () {
    debugger;


    var markers = JSON.parse('<%=ConvertDataTabletoString() %>');

    var mapOptions = {
    center: new google.maps.LatLng(markers[0].Latitude, markers[0].Longitude),
    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.Latitude, data.Longitude);
    var marker = new google.maps.Marker({
    ,
    map: map,
    title: data.Name
    });

    (function (marker, data) {

    google.maps.event.addListener(marker, "click", function (e) {
    //infoWindow.setContent(data.description);
    if (data.totallocker > 0)
    {
    infoWindow.setContent('<p>Branch Name: ' + data.Name + '</p>' +
    '<p>Address: ' + data.Address + '</p>' +
    '<p>available Locker: ' + data.totallocker + '</p>' +
    '<a href="#" value=' + data.branchid + ' onclick="myFunction(this)">Apply Locker</a>'
    );
    }
    else {
    infoWindow.setContent('<p>Branch Name: ' + data.Name + '</p>' +
    '<p>Address: ' + data.Address + '</p>' +
    '<p>available Locker: ' + data.totallocker + '</p>'

    );
    }
    infoWindow.open(map, marker);
    });
    })
    (marker, data);

    }

    }

    Friday, February 5, 2016 6:03 AM

All replies

  • User-366017857 posted

    Hi,

    You can do like this please rfer this code

    $("#updateMap").click(function(){
    
        var lat = parseFloat(document.getElementById('markerLat').value);
        var lng = parseFloat(document.getElementById('markerLng').value);
        var newLatLng = new google.maps.LatLng(lat, lng);
    
        if (marker != undefined)
            marker.setPosition(newLatLng);
        else
            marker = new google.maps.Marker({
                position: newLatLng,
                map: map,
                draggable: true
            });
        });
    Friday, February 5, 2016 7:00 AM
  • User229488726 posted

    thanks but my Lat and Lng value come from database its not only 2 value .At a time  it came more  then 10 value from database when how can i do this  

    all values came into a  datatable . then i convert the value into list then i insert the value into the marker array .  

    Friday, February 5, 2016 7:07 AM