On Jan 6, 1:25 pm, "Henry P" <[email protected]> wrote:
> Hi there.
> I'm wondering how it is possible to add multiple event listeners to
> individual *results* returned from a local search.

It is.

> I tried (unsuccessfully) to do it.
> I can get the openinfowindowhtml to show "Clicked!" but it only works for
> opens for one of the markers no matter which one I click.
> Has anyone any examples? I can't seem to find any pertaining to what I'm
> trying to do.

See Mike Williams' tutorial.  Most likely pitfall #3 of the first
page.  A createMarker function would solve the problem.

> Here's my code:

Please read the posting guidelines and post a link to your map that
shows the problem...

  -- Larry


> function load() {
> if (GBrowserIsCompatible()) {
>
> var map = new GMap2(document.getElementById("map"));
> var localSearch = new GlocalSearch();
>
> map.addControl(new GSmallMapControl());
> map.addControl(new GMapTypeControl());
>
> var geocoder = new GClientGeocoder();
>
> var address = "My Company" + ", " + "My City" + ", " + "My State"+"My
> ZipCode" + "," + "My Country";
> var localSearchString = "My Company" + ", " + "My City" + ", " + "My
> Country";
>
> geocoder.getLatLng(
> address,
> function(p) {
> if (!p) {
> alert(address + " not found");} else {
>
> map.setCenter(p, 13);
> var marker = new GMarker(p);
> map.addOverlay(marker);
> marker.openInfoWindowHtml("<font>My Company Name<br>My Street <br>My City
> <br>My Country</font>");
> localSearch.setSearchCompleteCallback(null,
>        function() {
>           if(localSearch.results.length > 0) {
>              for(var i=0; i<localSearch.results.length; i++) {
>                 var resultLat = localSearch.results[i].lat;
>                 var resultLng = localSearch.results[i].lng;
>                 var localPoint = new GLatLng(resultLat,resultLng);
>                 var resultMarker = new GMarker(localPoint);
>                 map.addOverlay(resultMarker);
>                 GEvent.addListener(resultMarker, "click", function() {
>                    resultMarker.openInfoWindowHtml("Clicked!");
>                 });
>              }
>           }
>        });
> localSearch.execute(localSearchString);
>
> }
> }
> );
> }
> }
>
> </script>
> </head>
> <body onload="load()" onunload="GUnload()">
> <div id="map" style="height: 300px"></div>
> </body>
> </html>
>
> Thank you for your help
> Henry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to