我已经看到有可能用"静态"将搜索范围限制到某个区域(有组件限制),我也看到在JavaScript API的发行版3.exp(将是3.14)中,新类google.maps.GeocoderComponentRestrictions已经出现.我还没有看到过应该如何使用这个类.有没有人有关于此的更多信息?
我正在寻找一种从 Google API 中提取内置属性边界数据的方法,以了解在哪里突出显示信息需求的区域。
绘制多边形很容易,但我想知道在哪里以更自动化的方式绘制它。也许类似于用于提取地址位置的地理编码,但不幸的是,地理编码器仅提供中心坐标和边界框(用于屏幕导航)。
Google 是否以某种形式提供此属性数据?
谢谢
html javascript google-maps google-maps-api-3 google-geocoder
我想将 Google Maps Api 的自动完成功能限制在特定区域。\n我已经找到了解决方案,但效果并不理想。
\n\n如何停用自动完成的事件“keyup”或删除预测?在解决方案中,我添加了一个 setTimeOut 函数来删除预测,但如果可能的话,我想要另一个解决方案。
我需要在街道名称后面放置一个空格来显示预测。
欢迎任何帮助!\n谢谢
\n\n**
\n\nlet autocomplete = new google.maps.places.Autocomplete(document.getElementById(\'autocompleteInput\'), {\n types: [\'geocode\'],\n componentRestrictions: { country: \'fr\' }\n});\n\nlet input = document.getElementById(\'autocompleteInput\');\nlet inputValue = (<HTMLInputElement>document.getElementById(\'autocompleteInput\'));\nlet help = document.getElementsByClassName(\'pac-container\');\n\n\ngoogle.maps.event.addDomListener(input, \'keyup\', function (e) {\n if (this.value !== \'\') {\n let valueup = help.item(0).childElementCount - 1;\n if (this.value.length > 1) {\n for (let i = valueup; i <= valueup && i >= 0; i--) {\n help.item(0).children.item(i).remove();\n }\n }\n\n let …Run Code Online (Sandbox Code Playgroud) 我正在使用Geocoder API,当返回结果时,双向数据绑定不起作用.数据不会在视图中刷新.如果我手动更改任何其他属性,数据会刷新...所以,我google(很多)并找到了一个使用的解决方案ngZone.这就是我所做的:
getLocation(address: string): void {
var mygc = new google.maps.Geocoder();
this._ngZone.runOutsideAngular(() => {
mygc.geocode({
'address': address
}, (results, status) => {
var data: any = results[0];
this._ngZone.run(() => {
this.myObject.myData = {
lat: data.geometry.location.lat(),
lng: data.geometry.location.lng()
};
});
});
});
}
Run Code Online (Sandbox Code Playgroud)
所以我有几个问题:
ngZone用?文档很松散......runOutsideAngular()那么好,使用它的重点是什么?该示例还包括此函数调用,因此我也实现了它.但它没有它也可以工作......myObject在视图中还有其他方法可以刷新吗?谢谢!
我试图阅读一些关于这个问题的类似主题。但不幸的是我仍然遇到同样的问题。
所以基本上,我正在尝试使用 Goole Geocode API 将我的纬度经度的地理编码反转为人类可读的地址。
为了更安全,我对我的 iOS 应用程序的 API 密钥给予了更多限制。这是密钥的应用限制
而且我还给出了这样的 API 密钥限制,我确定我已经包含了地理编码 API

但是当我运行应用程序时......我收到错误消息
此 IP、站点或移动应用程序无权使用此 API 密钥。从 IP 地址 xxxxxx 收到的请求为空引用
这里出了什么问题?如果限制设置为无,它工作正常
google-maps google-maps-api-3 ios google-geocoder google-cloud-platform
我想知道Google如何进行地理编码和解决?它是否像DNS查找一样工作,它们有一个大地址表,这是一个地理编码的哈希,或者是否有任何有趣的几何图形?如果它是一个大哈希表,他们是如何收集所有数据的呢?
根据Google Map的Geocode API文档:
https://developers.google.com/maps/documentation/geocoding/index#GeocodingRequests
你可以简单地调用地理编码请求地址,如下所示:
但是,根据此部分,每天有2500个请求的使用限制.
我有一个纬度和经度,我需要取国.
我用这个:
$geocode_stats = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?latlng=".$deal_lat.",".$deal_long . "&sensor=false");
$output_deals = json_decode($geocode_stats);
$country = $output_deals->results[2]->address_components[4]->long_name;
Run Code Online (Sandbox Code Playgroud)
有时它会提供正确的国家/地区名称,但有时会提供空白值,有时会返回城市名称.
有人可以帮忙吗?
我使用 Google 提供的简单 URL 来查找邮政编码。
http://maps.googleapis.com/maps/api/geocode/json?address=90210&sensor=true
此 URL 将返回全世界的结果,但如何将这些结果限制为仅限美国?我查了一下,但找不到任何东西。当可能有办法添加到 URL 并获取以下内容时,我不想编写过多的代码来确保不存在任何美国地址:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
Run Code Online (Sandbox Code Playgroud)
如果根本没有结果,这就是 API 返回的内容。容易多了。
我正在尝试获取谷歌地图中可拖动标记的纬度和经度。我需要这些值直接进入<input type="text">. 我设法做到了这一点,唯一的问题是我不知道如何添加地理编码器以便用户可以输入自己的地址并获取纬度和经度,但他们也需要将标记拖入如果谷歌地图不准确。我会把我的代码放在这里。感谢有人可以提供帮助。
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
</head>
<body>
<input type="text" id="latitude" placeholder="latitude">
<input type="text" id="longitude" placeholder="longitude">
<div id="map" style="width:500px; height:500px"></div>
<p><input class="postcode" id="Postcode" name="Postcode" type="text">
<input type="submit" id="findbutton" value="Find" /></p>
</body>
</html>
JavaScript
function initialize() {
var $latitude = document.getElementById('latitude');
var $longitude = document.getElementById('longitude');
var latitude = 50.715591133433854
var longitude = -3.53485107421875;
var zoom = 16;
var geocoder;
var LatLng = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: zoom,
center: …Run Code Online (Sandbox Code Playgroud) google-geocoder ×10
google-maps ×6
angular ×1
autocomplete ×1
geocode ×1
geocoding ×1
geolocation ×1
html ×1
ios ×1
javascript ×1
php ×1