THANKS
On Mon, Jun 28, 2010 at 8:43 AM, mandvika rathore <[email protected]>wrote:
> Hi I have developed a custom search form that gives the result with a
> custom marker whihc I call as gSmallIcon = new google.maps.Icon();
>
> My results are stored in gcurrentResults array- I process it using
> the following code- for (var i = 0; i < gCurrentResults.length; i++) {
> if (!gCurrentResults[i].selected()) {
> gMap.removeOverlay(gCurrentResults[i].marker());
> }
> }
>
> gCurrentResults = [];
> for (var i = 0; i < gLocalSearch.results.length; i++) {
> gCurrentResults.push(new
> LocalResult(gLocalSearch.results[i]));
> }
>
> function LocalResult(result) {
> this.result_ = result;
> this.resultNode_ = this.unselectedHtml();
>
> document.getElementById("searchwell").appendChild(this.resultNode_);
> gMap.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
> gMap.removeOverlay(this.marker());
> this.marker_ = null;
> gMap.addOverlay(this.marker(G_DEFAULT_ICON));
>
> // Add our result to the saved set
>
> document.getElementById("selected").appendChild(this.selectedHtml());
>
> // Remove the old search result from the search well
> this.resultNode_.parentNode.removeChild(this.resultNode_);
> }
> }
>
> // Returns the HTML we display for a result before it has been
> "saved"
> 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() {
> gMap.closeInfoWindow();
> this.select();
> gSelectedResults.push(this);
> });
> container.appendChild(saveDiv);
> return container;
> }
>
> // Returns the HTML we display for a result after it has been
> "saved"
> LocalResult.prototype.selectedHtml = function() {
> return this.result_.html.cloneNode(true);
> }
>
> // Returns true if this result is currently "saved"
> LocalResult.prototype.selected = function() {
> return this.selected_;
> }
>
>
> what I want to do is that when this markernext to the result is
> clicked it should point to the marker in the map with the info. HOw
> can i bind the markers next to the results and in the map??
>
> --
> 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]<google-ajax-search-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-ajax-search-api?hl=en.
>
>
--
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.