function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
samrat.1985@lntinfotechsamrat.1985@lntinfotech 

Issue in google map the text in the search box is dilplayed with a + sign in between

This is the javascript function which prepares the search string.

 

function gup( name )

 {

 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,\\\]);

 var regexS = "[\\?&]"+name+"=([^&#]*)";

var regex = new RegExp( regexS );

 var results = regex.exec( window.location.href );

 if( results == null ) return "";

else return results[1];

}

 

But once the text is searched then it is displayed with a plus sigm in between words.

 

For example

if i am searching for "CA Street California"

it gets replaced by "CA+Street+California"

Pradeep_NavatarPradeep_Navatar

Here all the spaces are automaticaly replaced by + sign so you have to use an inbuilt JavaScript Replace method to remove all the + signs before you return this from the JavaScript Function.

 

Hope this helps.

samrat.1985@lntinfotechsamrat.1985@lntinfotech

Hi pradeep,

 

Can you post a little demo code. As i tried doing that using str.replace("+"," ")

but it doesnot seem to work

b-Forceb-Force

here is updated script for you

 

function replacePlus(strInput)
{
    var temp = this;
    var index = temp.indexOf("+");

        while(index != -1)
	{

            temp = temp.replace(strInput," ");

            index = temp.indexOf(strInput);

        }

        return temp;

}
function gup( name )

{

 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,\\\]);

 var regexS = "[\\?&]"+name+"=([^&#]*)";

var regex = new RegExp( regexS );

 var results = regex.exec( window.location.href );

 if( results == null ) return "";

else 
return replacePlus(results[1]);

}

 

 

Thanks,

Bala