Skip Navigation

[Resolved] Display a random address on Google mao

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.76 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 2 voices.

Last updated by Jeffrey 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#906510

Hello, I am building a site like a rental vacation site, for privacy purpose, most of the Hosts don't want to show the exact house address on the map, in order to show up a rough area to help guests know where is the house, most of the sites set a random address I guess

for example, just display randomly last 2 digits house number, that will not only show up a rough area but also protect hosts privacy.

For example. Address: 1000 5th Ave, New York, NY 10028, if set random last 2 digits, the house number should be 1000 to 1099.

my question is, I will input exactly information, how to output a random 2 digits house number on Google map?

Thank you!

#906571

Hello,

There isn't such a feature within Toolset maps, but you can try to create a custom shortcode:
https://codex.wordpress.org/Function_Reference/add_shortcode

Get the address field value:
https://toolset.com/documentation/customizing-sites-using-php/functions/#address

Change it to what you want.

#907160

🙂 🙂 I think I am not capable to do this, it is very hard for me. can you help me resolve it? if you can
please go to my site, and follow this link /wp-admin/admin.php?page=ct-editor&ct_id=186&action=edit , you can see the my location field and shortcode to display map and markers on the bottom, just show random address here. /wp-admin/admin.php?page=wpcf-edit&group_id=28 the custom google map field here. the link of host posts here /wp-admin/admin.php?page=view-templates

You can see the access information by click on this link https://toolset.com/forums/topic/need-help-with-js-math-calculation/ I opened another ticket

Thank you so much whether you do or not! 🙂

#907256

Please elaborate the question with more details:
how to output a random 2 digits house number on Google map

Where do you want to output the custom address field value?
As a raw text or in the marker popup window?

Same as previous ticket, you can post your question in Chinese.

#907267

举例说: Address: 1000 5th Ave, New York, NY 10028, 在谷歌地图字段, 当我输入这个地址的时候, 请按照 1000 5th Ave, New York, NY 10028, “1000 ”这个是门牌号, 将这个门牌号 的尾数 两个数字 随机化 的展示marker, 也就是说 地址还是确切的地址,但是显示的的Marker 已经按照门牌号的末尾两位数 随机化了。

或者随机化输入地址的经纬度的最后两位数。
或者说 输入确切的地址, 但是使用经纬度的最末尾两位数 随机化? 这样好像更准确, 达到的效果是 大致区域不变,但是 显示的不是确切的地址门牌号,

mysite.com/wp-admin/admin.php?page=ct-editor&ct_id=186&action=edit 你可以看到内容模板, 在最底下有一个地图,
mysite.com/wp-admin/admin.php?page=wpcf-edit&group_id=28 这里的 my location 是谷歌地图字段

mysite.com/host/jian-da-li/ 前段可一测试一下看看

非常感谢!

#907335

可能有误会了,不是让你翻译你的贴子,我的问题是你打算在哪里显示这个自定义shortcode。

我在你的网站上做了一下改动:
1)添加代码如下:
hidden link

2)修改layout, 添加了一个visual editor cell:
hidden link

<p>原先的地址:[types field='my-location'][/types]</p>
<p>生成的新地址:[random_address]</p>

在页面最下部可以看到测试结果:
hidden link
这只是一个示例,你需要根据自己的网站修改代码。

#907980

Hi Luo

谢谢你的帮忙,我测试了一下代码,并仔细考虑了一下,根据实际情况 可能会有纯字母的门牌号,或者门牌号少于两位的情况,尤其是纯字母的情况下 随机数将会是地址偏移到不可预期, 所以我想能否设定经纬度的小数点后两位的随机呢?我已经测试过 小数点后两位的偏移会是可以控制的,这样既保护了用户的隐私,又能标识出地址的大致范围

例如 Longitude -122.351110 从1110随机
Latitude 47.619746 从 9746 随机

从小数点后两外 无论怎样都会在一个不算太大的范围内

所以能否再帮我改一下这段代码呢? 多谢多谢! :)

#908005

这个是新问题,你原先提出的问题为: “门牌号 的尾数 两个数字 随机化 ”
https://toolset.com/forums/topic/display-a-random-address-on-google-mao/#post-906510
我在上面已经给出了一个例子:
https://toolset.com/forums/topic/display-a-random-address-on-google-mao/#post-907335

按照我们的支持政策,我们是不提供这种custom codes,只能为你提供例子参考,请你为新问题开一个新帖。 谢谢!

#908023