检查地址是否在区域地图中 [英] Check if an address is within an area map

查看:104
本文介绍了检查地址是否在区域地图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚安,

我目前正在设计和编程我的业务网站,我有一些编程技巧,我喜欢学习litle来点亮。



我一直在寻找和调查,但不清楚。



我需要的是用户客户)可以把他/她的地址,并验证它是否在我们的交付区域内。



目前我在谷歌地图上设计了这个图层:



https:// www.google.com/maps/d/u/0/viewer?mid=1E3bcIm6Dy4icmTA4S-hEqOZeHpU



我使用的是什么技术?



我只需要一个处方公式的输入文本就可以写出地址,并用一个OK或一个抱歉的响应。

我找到的所有信息都是用于计算路线的问题和解决方案,并且只需要验证一个区域内的地址。现在我知道了aut并保存地址进行验证。现在我只需要知道我可以如何验证我在这个领域的方向。



借口我的英语,非常感谢! :

解决方案

以下是您的草图:
https://jsfiddle.net/zw6f78xk/
$ b

首先 Place Autocomplete 用于输入一个地址,该地址为您提供地址的位置。



然后检查位置 a>是否在多边形内。

  google.maps.geometry.poly.containsLocation(place.geometry.location,polygon )

希望这有助于您。

更新:



但现在因为您的谷歌地图上已经有了多边形,所以很容易修改它的形状,检索其坐标。
只需将 editable:true 添加到多边形选项,然后您可以手动修改它,最后您可以像这样获取坐标:

  google.maps.event.addListener(多边形,'click',函数(evt){
var pathArray = polygon.getPath()。 getArray();
for(var i = 0; i< pathArray.length; i ++){
console.log(pathArray [i] .toUrlValue());
};
});

所以点击多边形就会记录它的路径。



更新2:



对输入的地址进行地理编码(但不能从自动完成中选择)地址。
https://jsfiddle.net/zw6f78xk/3/


Goodnight,

I am currently designing and programming the website of my business, I have some programming skills, I like to learn litle to litle.

I've been looking and investigating but do not get to be clear.

The need I have is that a user (client) can put his/her address and to validate if it is within our delivery area.

Currently I have designed this layer on google maps:

https://www.google.com/maps/d/u/0/viewer?mid=1E3bcIm6Dy4icmTA4S-hEqOZeHpU

What is the technology that I use?

I just need an input text of a formulary to write the address and respond with an OK or a sorry.

All the information that I find are questions and solutions to calculate routes and only need to verify an address within an area.

now I know as autofill and get save the address to verify. Now I just need to know how I can verify that direction in my area.

Excuseme by my english and thank you so much! :)

解决方案

Here is a sketch for you: https://jsfiddle.net/zw6f78xk/

First the Place Autocomplete was used to input an address, which gives you the location of the address

Then the location is checked whether it is inside the polygon.

google.maps.geometry.poly.containsLocation(place.geometry.location, polygon)

Hope this helps.

Update:

But now because you already have the polygon on your google map, it is easy to modify its shape and retrieve its coordinates. Just add editable: true to the polygon options then you can modify it manually and finally you can get the coordinates for example like this:

google.maps.event.addListener(polygon, 'click', function(evt) { 
    var pathArray = polygon.getPath().getArray();
    for (var i = 0; i < pathArray.length; i++){
        console.log(pathArray[i].toUrlValue());
    };
});

So clicking on the polygon it logs its path.

Update 2:

Geocoding the typed (but not selected from the autocomplete) address. https://jsfiddle.net/zw6f78xk/3/

这篇关于检查地址是否在区域地图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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