Wow...what a detailed reply... :)

Will try this out and let you know...

Thanks a lot :)

On Mar 13, 6:16 pm, Jeremy Geerdes <[email protected]> wrote:
> To do this, you need to override the GSmapSearchControl's default  
> setMarkers method.  There are a couple of ways you can do this,  
> depending on what you're trying to accomplish. If you have other  
> customizations that you're wanting to do, it would probably be  
> worthwhile to just download and roll your own version of  
> gsmapsearch.js?mode=new that includes the customizations. If not, then  
> it will suffice to use Javascript to override the GSmapSearchControl's  
> default .setMarkers() method.  This can be done simply by including  
> the following before the line reading "new  
> GSmapSearchControl(" (without the quotation marks) in the  
> LoadMapSearchControl function that was generated by the wizard:
>
> GSmapSearchControl.prototype.setMarkers = function() {
>
>    // result scroller
>    this.currentResultIndex = 0;
>    this.markers = new Array();
>    var bestResultUrl = null;
>
>    if ( this.gs.results && this.gs.results.length > 0) {
>
>     var notGood=0; // Jeremy Geerdes' custom code
>
>      for (var i = 0; i < this.gs.results.length && i < 16; i++) {
>        var result = this.gs.results[i];
>
>        // Jeremy Geerdes' custom code
>        var latlng = new GLatLng(parseFloat(result.lat),  
> parseFloat(result.lng));
>        var radiusInKM = 40; // this is the radius in kilometers
>        if (this.mapCenter.distanceFrom(latlng) > radiusInKM * 1000) {
>         notGood++;
>         continue;
>        }
>        // end Jeremy Geerdes' custom code
>
>        var icon = this.unselectedIcon;
>        if (this.letteredIconMode) {
>          icon = this.letteredIcons[i-notGood]; // Jeremy Geerdes'  
> custom code
>        }
>        this.markers.push(new GSmapscLocalResult(this, result, icon, i));
>
>        // find the first, non-address result and hold on to it for the  
> more-link
>        if (bestResultUrl == null && !result.addressLookupResult ) {
>          bestResultUrl = result.url;
>        }
>      }
>      if(this.markers.length==0){return;} // Jeremy Geerdes' custom code
>      GSmapsc_cssSetClass(this.prevNext, "gsmc-prevNext gsmsc-prev-next-
> active");
>      GSmapsc_cssSetClass(this.appContainer, "gsmsc-appContainer gsmsc-
> active");
>      this.gmap.checkResize();
>      this.idle = false;
>      this.selectMarker(0);
>
>      // stuff in a more results link
>      if (this.resultsList) {
>        if (bestResultUrl) {
>          // NOW, take the URL and nuke from &latlnt.*&near ->&near
>          var newUrl = bestResultUrl.replace(/&latlng=.*&near/,"&near");
>          var moreDiv = GSmapsc_createDiv(null, "gsmsc-result-list-more-
> results");
>          var alink = GSmapsc_createLink(newUrl, GSearch.strings["more-
> results"],
>                                         this.linkTarget, "gsmsc-result-
> list-more-results");
>          moreDiv.appendChild(alink);
>
>          var clearDiv = GSmapsc_createDiv(GSearch.strings["clear-
> results-uc"],
>                                  "gsmsc-result-list-clear-results");
>          clearDiv.onclick = GSmapsc_methodClosure(this,
>
> GSmapSearchControl.prototype.goIdle,
>                                              []);
>          // create a table for these to sit within
>          var table = GSmapsc_createTable("gsmsc-result-controls");
>          var row = GSmapsc_createTableRow(table);
>          var moreTd = GSmapsc_createTableCell(
>                          row, "gsmsc-result-list-more-results");
>          var clearTd = GSmapsc_createTableCell(
>                          row, "gsmsc-result-list-clear-results");
>          moreTd.appendChild(moreDiv);
>          clearTd.appendChild(clearDiv);
>          this.resultsList.appendChild(table);
>        }
>      }
>    }
>
> }
>
> A couple of things to note about this code.  First, it is essentially  
> the standard method, with just a couple of additions and alterations.  
> These are commented.  Second, if you want to change the radius (which  
> is presently 40km), you need to change the 40 on the line starting  
> "var radiusInKM = " (without the quotation marks). And third, for  
> people in the US that might want to use miles instead of kilometers,  
> change that same line to something like the following:
>
> var radiusInKM = 40 / .621371192;
>
> In this case, you would be setting the radius to 40 miles.
>
> And if you're looking for an example of this at work, check out the  
> link below:
>
> http://jgeerdes.home.mchsi.com/playground/t7.html
>
> Jeremy R. Geerdes
> Effective website design & development
> Des Moines, IA
>
> For more information or a project 
> quote:http://jgeerdes.home.mchsi.comhttp://jgeerdes.blogspot.comhttp://jgeerdes.wordpress.com
> [email protected]
>
> Unless otherwise noted, any price quotes contained within this  
> communication are given in US dollars.
>
> If you're in the Des Moines, IA, area, check out Debra Heights  
> Wesleyan Church!
>
> And check out my blog, Adventures in Web Development, 
> athttp://jgeerdes.blogspot.com
>   !
>
> On Mar 13, 2009, at 5:51 AM, Sumedh wrote:
>
>
>
> > Hi Friends,
>
> > I am trying to use GSmapSearchControl...
>
> > Basic code is working...now I want to do some customizations...
>
> > To begin with, how can I restrict the local search to execute only for
> > say a 10 kms radius from center...? The problem is, if it doesn't find
> > anything nearby (which is frequently possible in India), then it just
> > goes somewhere 40 kms away, which I don't want...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" 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-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to