Google maps api 3 CEFSharp修改或截断Google Maps v3 api中的地理代码地址数据
要复制,请从此处下载CefSharp: 并运行CefSharp.WinForms.Example 现在在您的浏览器和浏览器上运行my fiddle: 我添加了一个警报,在点击时显示完整的地址数据(街道号码、路线、社区、地点、行政区级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别 将浏览器上显示的数据与浏览器上显示的数据进行比较 问题是: 在我的浏览器中,位置显示为“Culiacán Rosales”,但在Cef浏览器中,它被截断为“Culiacán”。这个国家的行为也很怪异,Cef显示的是“墨西哥”而不是“墨西哥”(未注) 我即将退出cef,因为在这个问题上我找不到谷歌匹配,也不知道如何解决它 这是小提琴的代码,因为它不会永远持续:Google maps api 3 CEFSharp修改或截断Google Maps v3 api中的地理代码地址数据,google-maps-api-3,lang,cefsharp,Google Maps Api 3,Lang,Cefsharp,要复制,请从此处下载CefSharp: 并运行CefSharp.WinForms.Example 现在在您的浏览器和浏览器上运行my fiddle: 我添加了一个警报,在点击时显示完整的地址数据(街道号码、路线、社区、地点、行政区级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级别级
<!DOCTYPE html>
<html>
<head>
<title>Google Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<link href="MapStyle.css" rel="stylesheet" type="text/css" media="all"/>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<script>
var map;
var geocoder;
function initialize() {
var placeMarkers = [];
geocoder = new google.maps.Geocoder();
var aquamiller = new google.maps.LatLng(
24.832956,
-107.389775);
var mapOptions = {
zoom: 16,
center: aquamiller,
};
map = new google.maps.Map(
document.getElementById('map-canvas'),
mapOptions);
createSearchBar(map, placeMarkers);
google.maps.event.addListener(
map,
'click',
function(e) {
getAddress(e.latLng, function(address) {
alert(
address.street_number + ', ' +
address.route + ', ' +
address.neighborhood + ', ' +
address.locality + ', ' +
address.administrative_area_level_2 + ', ' +
address.administrative_area_level_1 + ', ' +
address.country + ', ' +
address.postal_code);
});
});
}
function getAddress(latLng, callBack)
{
geocoder.geocode({'latLng': latLng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var address = {};
var components = results[0].address_components;
for (var i = 0 ; i< components.length ; i++) {
address[components[i].types[0]] = components[i].long_name;
}
callBack(address);
}
else {
alert('No results found');
}
}
else {
alert('Geocoder failed due to: ' + status);
}
});
}
function createSearchBar(map, markers)
{
var input = /** @type {HTMLInputElement} */(document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var searchBox = new google.maps.places.SearchBox(/** @type {HTMLInputElement} */(input));
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
console.log(places);
for (var i = 0, marker; marker = markers[i]; i++) {
marker.setMap(null);
}
markers = [];
var bounds = new google.maps.LatLngBounds();
for (var i = 0, place; place = places[i]; i++) {
var image = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
// Create a marker for each place.
var marker = new google.maps.Marker({
map: map,
icon: image,
title: place.name,
position: place.geometry.location
});
markers.push(marker);
bounds.extend(place.geometry.location);
console.log(place.geometry.location);
}
map.fitBounds(bounds);
map.setZoom(16);
});
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
searchBox.setBounds(bounds);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<style>
#target {
width: 345px;
}
</style>
</head>
<body>
<input id="pac-input" class="controls" type="text" placeholder="Search Box">
<div id="map-canvas"></div>
</body>
</html>
谷歌地图
html,正文,#地图画布{
身高:100%;
边际:0px;
填充:0px
}
var映射;
var地理编码器;
函数初始化(){
var=[];
geocoder=新的google.maps.geocoder();
var aquamiller=new google.maps.LatLng(
24.832956,
-107.389775);
变量映射选项={
缩放:16,
中心:阿奎米勒,
};
map=新建google.maps.map(
document.getElementById('map-canvas'),
地图选项);
createSearchBar(地图、地点标记);
google.maps.event.addListener(
地图,
“点击”,
职能(e){
getAddress(例如latLng、函数(地址){
警觉的(
地址.街道号+','+
address.route+','+
address.neighbor+','+
address.locality+','+
address.Administration_area_level_2+,'+
address.Administration_area_level_1+','+
address.country+,'+
地址(邮政编码);
});
});
}
函数getAddress(latLng,回调)
{
geocoder.geocode({'latLng':latLng},函数(结果,状态){
if(status==google.maps.GeocoderStatus.OK){
如果(结果[0]){
var地址={};
var components=结果[0]。地址\组件;
对于(var i=0;i
嘿,再等一次,我看到我的标准Chrome 35和IE 10都有相同的行为(在“墨西哥”中缺少“Rosales”和重音)
所以,也许这与丢失的CEF语言包有关:。。您使用的NuGet可能只有en US.pak
。。。使用您的小提琴示例进行了更多测试。在我的安装中删除es.pak没有帮助。但如果我在地图的搜索框中搜索“Sønderborg,丹麦”,我会看到类似的情况。(在那里的一些地方,它说“S**o**nderborg”,没有“ø”),那么你确定它与浏览器相关,而不仅仅是谷歌API吗
更新使用language=es提问
如:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=es&libraries=places"></script>
改变谷歌API的响应。目前正在使用我的iPad和你的小提琴进行验证 您可以使用CEF二进制下载中的
cefclient.exe
将其隔离到CEF或CefSharp吗?你使用哪一个CefSharp版本?我使用这个NuGet:主要是因为我需要RegisterJsObject与winforms中的Google地图交互。你想让我试用的二进制文件和cefclient.exe在哪里?这是休息室吗