tags:

views:

26

answers:

1

How I can add external control like click event to any anchor out side of map to open a marker. Is there any stand alone example or can any one guide me how I can achieve this.

here is example but he is using his library. I can not use his library because my most of the code is already completed.

http://vigetlabs.github.com/jmapping/examples/category_function.html

A: 

It sounds like you are just trying to open an info window based on a click event on some DOM element?

If that is the case, you just need to add an onClick handler to the DOM element and call a javascript function that can locate the appropriate GMarker object and trigger it's click event:

// gmarkers is an array of markers that we added to the map
var gmarkers = []; 

function triggerClick (indexofMarker)
{
    GEvent.trigger(gmarkers[indexofMarker], "click");
}

You can find an example of this here (source).

Cannonade
A common mistake when doing this sort of thing is to forget that Javascript launched from HTML runs in global context and can only access global variables and functions.If you create your map and markers inside an onload function, as recommended by the Google documentation, then your map and markers end up as local variables of that function, and therefore not accessible in global context.
Mike Williams
You can stick your newly created *GMarkers* in an array in the global context and access them from your *triggerClick* function (see the example). @mike-williams - Were you just speaking generally, or was there a specific problem with the example ?
Cannonade