地理编码限制问题
Geocoding limit problems
我有一个页面,用户必须在地图上选择一个地方。他仍然可以搜索它。
在移动标记时,我想让他知道"他在哪里",这个值也存储在一个隐藏的输入中,就像纬度和经度一样,这样以后可以用来在数据库中插入值
一切都很好,只是在我插入地理编码功能后(可能是巧合),搜索框无论如何都不起作用。它会显示结果,但当您单击时,不会发生任何事情。我试着删除地理编码,但仍然不起作用
我也得到了OVER_QUERY_LIMIT。这是我的代码:
function initialize() {
var geocoder = new google.maps.Geocoder();
var myLatlng = new google.maps.LatLng(-1.456688, -48.477586);
var mapOptions = {
zoom: 14,
minZoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable: true,
title: 'Hello World!'
});
google.maps.event.addListener(marker, 'position_changed', function() {
var lat = this.getPosition().lat();
var lng = this.getPosition().lng();
var latlng = new google.maps.LatLng(lat, lng);
document.getElementById('latitude').value = lat;
document.getElementById('longitude').value = lng;
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
document.getElementById('enderec').value = results[0].formatted_address;
$('.onde-esta').html(results[0].formatted_address);
} else {
alert("Sem resultados");
}
} else {
alert("Geocoder falhou: " + status);
}
});
});
// Create an Autocomplete and link it to the UI element.
var input = /** @type {HTMLInputElement} */ (
document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var searchBox = new google.maps.places.Autocomplete(
/** @type {HTMLInputElement} */
(input), {
types: ['geocode']
});
// Listen for the event fired when the user selects an item from the
// pick list. Retrieve the matching places for that item.
google.maps.event.addListener(searchBox, 'place_changed', function() {
var place = this.getPlace();
document.getElementById('enderecoo').value = place.formatted_address;
//when place has been found
if (place.geometry) {
marker.setOptions({
title: place.name,
position: place.geometry.location
});
if (place.geometry.viewport) {
marker.getMap().fitBounds(place.geometry.viewport);
} else {
marker.getMap().setCenter(place.geometry.location);
}
}
else {
marker.setOptions({
title: null
});
alert('Lugar não encontrado');
}
});
// Bias the SearchBox results towards places that are within the bounds of the
// current map's viewport.
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
searchBox.setBounds(bounds);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
是因为每次用户移动标记时都会对其进行地理编码吗?有没有什么可以让它只在用户放下标记时进行地理编码?提前感谢,Mateus
google.maps.event.addListener(Marker, "dragend", function(event) {
/*
User stopped dragging.
*/
});
相关文章:
- 我不知道我的编码有什么问题.(JavaScript)
- ajax表单提交的编码问题
- 导出为 CSV 时的编码问题
- 地理编码器 - IE8 中的编码问题
- 参数未正确传递给AJAX-编码问题
- 谷歌地图客户端地理编码“;OVER_QUERY_LIMIT”;问题
- AngularJS/Grunt编码问题
- 地理编码限制问题
- 编码百分比值时出现问题
- Outlook中的HTML锚定邮件主题编码问题
- 服务器编码的JSON数据出现问题,无法绘制图表
- NetSuite Restlet PDF 文件编码问题
- 使用地址进行地理编码 - over_query_limit问题
- Angular2 奇怪的硬编码对象与 http.get 对象问题
- 使用地理编码返回陆基坐标数组时出现问题
- 在安卓中使用 JavaScript 设置内容时出现编码问题
- Javascript到csv导出编码问题
- 为什么此字符编码问题仅在选定系统上出现
- JavaScript utf-8 编码问题
- 数学数组作业问题编码javascript