hi every one ,

i am having one problem.my search control displaying multiple results
and multiple markes,but i want that only first result(marker) should
display window info by default after search.other are after clicking
on marker.It all working fine but by default last marker displaying
windowinfo . So what to do?

i gave the totla code here but i think only that part i mention to
plan code may have some changes .....so please suggest




var center;
var gLocalSearch;
var gMap;
var gSelectedResults = [];
var gCurrentResults = [];
var gSearchForm;
 var gSmallIcon = null;


map = new GMap2(document.getElementById("divMap"));
 map.setCenter(new GLatLng(51.50874245880332,-107.9296875),3);
 map.addControl(new GSmallMapControl(), new GControlPosition
(G_ANCHOR_TOP_LEFT, new GSize(10,10)));
      map.addControl(new GMenuMapTypeControl(), new GControlPosition
(G_ANCHOR_TOP_RIGHT, new GSize(10,10)));
      map.addControl(new GScaleControl(), new GControlPosition
(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10)));

gSmallIcon = new google.maps.Icon();
      gSmallIcon.image = "Common/Images/chart_11.png";
      gSmallIcon.shadow = "http://labs.google.com/ridefinder/images/
mm_20_shadow.png";
      gSmallIcon.iconSize = new google.maps.Size(34, 34);
      gSmallIcon.shadowSize = new google.maps.Size(54, 34);
      gSmallIcon.iconAnchor = new google.maps.Point(17, 34);
      gSmallIcon.infoWindowAnchor = new google.maps.Point(17,2.83);


var searchFormDiv = document.getElementById("searchfrom");
        this.searchForm = new google.search.SearchForm( false ,
searchFormDiv);

        this.searchForm.setOnSubmitCallback(this, CaptureForm);

       gLocalSearch = new google.search.LocalSearch();
      gLocalSearch.setCenterPoint(map);
      gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);

       function OnLocalSearch() {

      if (!gLocalSearch.results) return;

      var searchWell = document.getElementById("googleSearchData");
      // Clear the map and the old search well
      searchWell.innerHTML = "";

      for (var i = 0; i < gCurrentResults.length; i++) {
        if (!gCurrentResults[i].selected()) {
          map.removeOverlay(gCurrentResults[i].marker());

        }
      }

      gCurrentResults = [];
      if(gLocalSearch.results.length != 0)
      {
      for (var i = 0; i < gLocalSearch.results.length; i++) {
        gCurrentResults.push(new LocalResult(gLocalSearch.results
[i]));
//        map.removeOverlay(gCurrentResults[i].marker());
//         map.closeInfoWindow();
          map.addOverlay(gCurrentResults[i].marker());


          if  (i==0)
          {


        SUGGESTED CODE




          }

      }

       var attribution = gLocalSearch.getAttribution();
      if (attribution) {
        document.getElementById("googleSearchData").appendChild
(attribution);

       }

        var first = gLocalSearch.results[0];
        map.setCenter(new google.maps.LatLng(first.lat, first.lng));
        animatedcollapse.toggle('googleSearchData');
        animatedcollapse.show('googleSearchData');
        animatedcollapse.hide('searchOptions');

         }
         else
              {
               map.closeInfoWindow();
               alert(searchForm.input.value + " is not found");
              }
    }

    // Cancel the form submission, executing an AJAX Search API
search.
    function CaptureForm(searchForm) {

  if(this.searchForm.input.value !='')
     {
      gLocalSearch.execute(this.searchForm.input.value);

    }
    else
    {
       if(gLocalSearch.results.length != 0)
    {
     map.removeOverlay(gCurrentResults[0].marker());
     map.closeInfoWindow();
     document.getElementById("googleSearchData").innerHTML = "";
     alert("Type what you're looking for into the Search box.");
    }
    else
    {
    alert("Type what you're looking for into the Search box.");
    }

    }

      return false;
    }

       function LocalResult(result) {
      this.result_ = result;
      this.resultNode_ = this.unselectedHtml();
      document.getElementById("googleSearchData").appendChild
(this.resultNode_);
      map.addOverlay(this.marker(gSmallIcon));
    }

    // Returns the GMap marker for this result, creating it with the
given
    // icon if it has not already been created.
     LocalResult.prototype.marker = function(opt_icon) {
      if (this.marker_) return this.marker_;
      var marker = new google.maps.Marker(new google.maps.LatLng
(parseFloat(this.result_.lat),
                                         parseFloat
(this.result_.lng)),
                               opt_icon);

       GEvent.bind(marker, "click", this, function() {
        marker.openInfoWindow(this.selected() ? this.selectedHtml() :
                                                this.unselectedHtml
());


      });
      this.marker_ = marker;
      return marker;
    }

     // "Saves" this result if it has not already been saved
    LocalResult.prototype.select = function() {
      if (!this.selected()) {
        this.selected_ = true;

        // Remove the old marker and add the new marker
        map.removeOverlay(this.marker());
        this.marker_ = null;
        map.addOverlay(this.marker(G_DEFAULT_ICON));


        // Remove the old search result from the search well
        this.resultNode_.parentNode.removeChild(this.resultNode_);

      }
    }

      LocalResult.prototype.unselectedHtml = function() {
      var container = document.createElement("div");
      container.className = "unselected";
      container.appendChild(this.result_.html.cloneNode(true));
      var saveDiv = document.createElement("div");
      saveDiv.className = "select";
      saveDiv.innerHTML = "Save this location";
      GEvent.bindDom(saveDiv, "click", this, function() {
        map.closeInfoWindow();
        this.select();
        gSelectedResults.push(this);
      });
      container.appendChild(saveDiv);
      return container;
    }

     LocalResult.prototype.selectedHtml = function() {
      return this.result_.html.cloneNode(true);
    }

    LocalResult.prototype.selected = function() {
      return this.selected_;


Thanks
--~--~---------~--~----~------------~-------~--~----~
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