谷歌地图自动完成删除空格并在地址字符串中插入加号(+)

Google Map Autocomplete remove blank space and insert plus(+) inside address string

本文关键字:插入 字符串 地址 删除 空格 谷歌地图      更新时间:2023-09-26

大家好,我有谷歌地图地址自动完成搜索框在我的页面上。当我按回车键时,我的

网址是这样的:
http://localhost/realestate-site/public/property_home?address=Birmingham AL

而不是这个,我希望我的网址看起来像这样,我想插入加号代替空格
http://localhost/realestate-site/public/property_home?address=Birmingham+AL

脚本:

predictionsDropDown.empty();
   $.each(predictions, function(i, prediction) {
     predictionsDropDown.append('<div>' +    $.fn.cityAutocomplete.transliterate(prediction.terms[0].value) + '</div'   +'<div>&nbsp;'+ $.fn.cityAutocomplete.transliterate(prediction.terms[1].value) + '</div');
        });

使用字符串替换函数应该可以满足您的需求。Javascript或PHP place函数都应该这样做。

爪哇语

string.replace(“ “,”+”)

.PHP

str_replace(" ","+","string");