地理位置邮政编码 [英] GeoLocation Zip Code

查看:31
本文介绍了地理位置邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码获取位置和城市,但如果此人给予我许可,则无法获取它以提供邮政编码.请让我知道这是否可以使用此代码.如果获得访问权限,它所做的就是填充文本字段.

I am using the following code for getting location and city, but can't get it to give me the zip code if the person gives me permission. Please let me know if this is possible to do with this code. All it is doing is populating a text field if given permission to access.

<script type="text/javascript">
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
     $("#location").val(position.address.city+", "+position.address.region);
  });
 }

推荐答案

试试 position.address.postalCode

查看我制作的以下演示以了解您的浏览器/设备支持什么

See the following demo i made to see what is supported by your browser/device

https://jsfiddle.net/gaby/Sx5cj/

这篇关于地理位置邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆