views:

1122

answers:

3

edited


code

//array store the markers

var googleMarker = [];

//this function get json object with the marker data
//place name,place id,place address.

function AjaxGetUserToPlaces(res)
{
    var l = res.value.length; 

    for(var i=0;i<l;i++)
    {
        var point = new GLatLng(res.value[i].lng,res.value[i].lat)
        map.addOverlay(createMarkerInfo(i,point,res.value[i].placeName,res.value[i].placeId));
        polylineArray.push(point);
    }
}

//the function create the openWindow for the marker.

function createMarkerInfo(i,latlng , placeName,placeId)
 {
    var marker = new GMarker(latlng);
    marker.value = placeId;

    GEvent.addListener(marker, 'click', function()
    { 
    marker.openInfoWindowHtml(''+
    '<a href='+baseUrl+'ui/pages/place/place.aspx?plid='+placeId+'>'+placeName+'</a>');
     });
     googleMarker[i] = marker

    return marker;
}



//this function occur when user click on one of the result.
//it gets the number in the array googleMarker.

function showMarkerInfoWindow(i)
{

//here i want to open the marker info window.
//pay attention, i dont have the html to put inside the infowindow
//i want just to show the infowindoe with the exising html 
//that created prevusly from the function createMarkerInfo

     googleMarker[i].openInfoWindowHtml();
}

i hope u ll understand me better thank very much

A: 

EDITED: If you have the co-ordinates, you can pass the values to your createMarker() function directly. Like this:

HTMLCODE:

<a href="javascript:void(0);" onMouseOver="javascript:createMarker(lat1,lng1,msg1);">List1</a>
<a href="javascript:void(0);" onMouseOver="javascript:createMarker(lat2,lng2,msg2);">List2</a>
<a href="javascript:void(0);" onMouseOver="javascript:createMarker(lat3,lng3,msg3);">List3</a>

JS CODE:

 function createMarker(x,y,msg) { 
    var point = new GLatLng(x,y);  
    var myHtml = msg;
    var baseIcon = new GIcon();
    baseIcon.shadow = "";
    baseIcon.iconSize = new GSize(20, 34);
    baseIcon.shadowSize = new GSize(37, 34);
    baseIcon.iconAnchor = new GPoint(9, 34);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);
    baseIcon.infoShadowAnchor = new GPoint(18, 25);
    var letteredIcon = new GIcon(baseIcon);
    letteredIcon.image = "http://www.google.com/intl/en_ALL/mapfiles/marker.png";
    markerOptions = { icon:letteredIcon };
    var marker = new GMarker(point,markerOptions); 
    GEvent.addListener(marker, "mouseover", function() {    
     map.openInfoWindowHtml(point, myHtml);  
    });
}
kayteen
I don't think that's really what he's looking for. He already has the marker in the google map. He has a separate list on the side, and when the user clicks on an item in the list he wants the corresponding marker to open it's info window as if someone had clicked on the marker itself.
Joseph
hey,thank for replayingits not the same because,in my case when the page load,it loaded all the marker and showing them on the mapand for each marker there is event listener marker.openInfoWindowHtml(''+ '<a href='+baseUrl+'ui/pages/place/place.aspx?plid='+placeId+'>'+placeName+'</a>'); });and on the left side there is result list of all the markers.i want that on click on one of the resultsit will open the infowindowHTML of the coorect marker.i dont want to add value to the infowindow againi want it just to open the correct marker with his infowindowthank you
avi
Sorry guys..!! :(I did some edit work according to the requirement.
kayteen
i edit my q again
avi
A: 

You can trigger a click event on the marker to open its info window:

GEvent.trigger(googleMarker[i], googleMarker[i].getLatLng());
CalebD
oki try this but it dosent worki search little bit in the intenet and found that it should be likeGEvent.trigger(googleMarker[i], "click"); thanx
avi
Yes that was my mistake, I wasn't paying attention to what I was typing. Glad it pointed you in the right direction!
CalebD
A: 

The Geocoder sample http://gmaps-samples-v3.googlecode.com/svn/trunk/geocoder/v3-geocoder-tool.html looks like just what you want to do (view source)

smirkingman