Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:31:31+00:00 2026-05-27T04:31:31+00:00

This map is to track multiple markers in a single view. The markers have

  • 0

This map is to track multiple markers in a single view. The markers have to be updated every 5 seconds from the server.
My infowindow disappears after each refresh. There is a json request every 5 seconds. when i click on the marker, the infowindow appears and is cleared as soon as during next json call. Can i devise a method/any solution to make it appear(dynamic) even after refreshing.

var map1;  
function map1_initialize( )  
{    
    setInterval(function() {
        var lat=new Array();var lng=new Array();var latlng = [];
 $.getJSON('web_services/latlong.php?option=4&user_id=<?php echo $user_id;?>', function(json) {
           $.each(json.Result.Data,function(i,gmap){

    lat[i]=gmap.latitude;
    lng[i]= gmap.longitude;
    latlng[i] = new google.maps.LatLng(lat[i], lng[i]);
/*google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
              infowindow.setContent(json.Result.Data[i].alias);
                console.log(json.Result.Data[i]);
              infowindow.open(map, marker);
            }
              })(marker, i)); */


    if ( google.maps.BrowserIsCompatible( ) )    
    {      
    map1 = new google.maps.Map2( document.getElementById( 'map' ) );      
    map1.addControl( new google.maps.LargeMapControl3D( ) );      
    map1.addControl( new google.maps.MenuMapTypeControl( ) );      
    map1.setCenter( new google.maps.LatLng( 0, 0 ), 0 );      
        for ( var i = 0; i < latlng.length; i++ )      
        {        
        var marker = new google.maps.Marker( latlng[ i ] ); 

        map1.addOverlay( marker );  

        }      

        var latlngbounds = new google.maps.LatLngBounds( );    

        for ( var i = 0; i < latlng.length; i++ )      
        {        
        latlngbounds.extend( latlng[ i ] );    

        }      
        map1.setCenter( latlngbounds.getCenter( ), map1.getBoundsZoomLevel( latlngbounds ) );

        GEvent.addListener(marker, 'click', function() {
              // When clicked, open an Info Window
            //alert(gmap.alias);
              marker.openInfoWindowHtml(gmap.alias);
            });
//gmap.alias is the alias name for the marker-loading it via json response

     }

    });

}); 


 }, 5000);



}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:31:32+00:00Added an answer on May 27, 2026 at 4:31 am

    With lot of R&D, i found out the answer!!!Hope this might help somebody…

    var json=[];
      function initialize() {
    
    // Create the map 
    // No need to specify zoom and center as we fit the map further down.
    var map = new google.maps.Map(document.getElementById("map_canvas"), {
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      streetViewControl: false
    });
    
    /*jQuery.extend({
    getValues: function(url) {
        var result = null;
    $.getJSON('web_services/latlong.php?option=4&user_id=21', function(json) {
        result = json;
              });
        return result;
    }
    });*/
    
        jQuery.extend({
    getValues: function(url) {
    //setInterval(function() { 
        var result = null;
        $.ajax({
        url: url,
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            result = data.Result.Data;
        }
    });
    return result;
    //},5000);
    }
    
    });
    
    
    
    setInterval(function() {
    var markers=$.getValues("web_services/latlong.php?   option=4&user_id=21");console.log(markers);
    
    
    
    
    
    // Define the list of markers.
    // This could be generated server-side with a script creating the array.
    /*var markers = [
      { lat: -33.85, lng: 151.05, name: "marker 1" },
      { lat: -33.90, lng: 151.10, name: "marker 2" },
      { lat: -33.95, lng: 151.15, name: "marker 3" },
      { lat: -33.85, lng: 151.15, name: "marker 4" }
    ];*/
    
    // Create the markers ad infowindows.
    for (index in markers) addMarker(markers[index]);
    function addMarker(data) {
      // Create the marker
      var marker = new google.maps.Marker({
        position: new google.maps.LatLng(data.latitude, data.longitude),
        map: map,
        title: data.alias
      });
    
      // Create the infowindow with two DIV placeholders
      // One for a text string, the other for the StreetView panorama.
      var content = document.createElement("DIV");
      var title = document.createElement("DIV");
      title.innerHTML = data.alias;
      content.appendChild(title);
    
      var infowindow = new google.maps.InfoWindow({
        content: content
      });
    
      // Open the infowindow on marker click
      google.maps.event.addListener(marker, "click", function() {
        infowindow.open(map, marker);
      });
    
      // Handle the DOM ready event to create the StreetView panorama
      // as it can only be created once the DIV inside the infowindow is loaded in the DOM.
    /*  google.maps.event.addListenerOnce(infowindow, "domready", function() {
        var panorama = new google.maps.StreetViewPanorama(streetview, {
            navigationControl: false,
            enableCloseButton: false,
            addressControl: false,
            linksControl: false,
            visible: true,
            position: marker.getPosition()
        });
      });*/
    }
    
    // Zoom and center the map to fit the markers
    // This logic could be conbined with the marker creation.
    // Just keeping it separate for code clarity.
    
     var bounds = new google.maps.LatLngBounds();
    for (index in markers) {
      var data = markers[index];
      bounds.extend(new google.maps.LatLng(data.latitude, data.longitude));
    }
    map.fitBounds(bounds);
    },5000);//call every of 5 secs.
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
In my routes.rb I have this: map.namespace :admin do |admin| admin.resources :galleries do |galleries|
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
I have a map defined like this std::map<some_key_type, std::string::iterator> mIteratorMap; And a huge string
If you have a float in MSSQLServer, to what do you map this in
I have this struct: struct Map { public int Size; public Map ( int
TLDR : I have an Openlayers map with a layer called 'track' I want
Hopefully this will be clear enough. I have a 2d map made of tiles,
i have a file that looks like this: TTITLE0=track name 1 TTITLE1=track name 2
like this: Groovy: map = ['a':1,'b':2] doubler = this.&doubleMethod map.each(doubler) println map What's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.