Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool openInfoWindowHtml doesn't work

    Hi

    I'm trying to do a very simple thing here: I have the map with the markers and clusters on it and I want to open an info window if user clicks on them. For some reason openInfoWindowHtml doesn't work, I cannot understand why.

    So here is my java script, may be you'll see what's wrong here?
    Thank you

    Code:
    var map;
    var centerLatitude = 0;
    var centerLongitude = 0;
    var startZoom = 1;
    
    //Create an icon for the clusters
    skipped
    
    //create an icon for the pins
    skipped
    
    
    function init() {
    map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
    
    updateMarkers();
    
    GEvent.addListener(map,'moveend',function() {
    updateMarkers();
    });
    }
    
    function updateMarkers() {
    
    //remove the existing points
    map.clearOverlays();
    //create the boundry for the data to provide
    //initial filtering
    skipped
    //log the URL for testing
    GLog.writeUrl('map_search.php?'+getVars);
    
    //retrieve the points
    var request = GXmlHttp.create();
    request.open('GET', 'map_search.php?'+getVars, true);
    request.onreadystatechange = function() {
    if (request.readyState == 4) {
    var jscript = request.responseText;
    var points;
    eval(jscript);
    
    //create each point from the list
    for (i in points) {
    var point = new GLatLng(points[i].lat,points[i].lng);
    var marker = createMarker(point,points[i].type,points[i].description);
    				
    map.addOverlay(marker);
    }
    }
    }
    request.send(null);
    }
    
    function createMarker(point, type, description) {
    //create the marker with the appropriate icon
    if(type=='c') {
    var marker = new GMarker(point,iconCluster,true);
    } else {
    var marker = new GMarker(point,iconSingle,true);
    }
    
    // open info window on click
    GEvent.addListener(marker,'click',function() {
    var markerHtml = description;
    marker.openInfoWindowHtml(markerHtml);
    });
    		
    return marker;
    }
     window.onload = init;

  • #2
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Me again..

    Just had a thought that may be the thing is that because I'm call createMarker function within the loop I need to put each marker in array to know for which particular marker openInfoWindowHtml method is called?
    Sorry if it doesn't make sense, but I'm really lost here and can't go any further until resolve this problem.
    Thanks again I'll appreciate if somebody has any ideas.
    Last edited by fikka; 09-06-2007 at 12:46 PM.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Instead of:
    Code:
    var points;
    eval(jscript);
    I suspect that you wanted to code:
    Code:
    var points=eval(jscript);
    in order to construct an object...Otherwise the variable points is undefined...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor View Post
    Instead of:
    Code:
    var points;
    eval(jscript);
    I suspect that you wanted to code:
    Code:
    var points=eval(jscript);
    in order to construct an object...Otherwise the variable points is undefined...

    Thanks but it's not the case, since "The eval() function evaluates a string and executes it as if it was script code."(c)js tutorial

    I have all the points and clusters on the map, it works fine. The only problem I'm having is with info windows.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •