我的谷歌地图距离查找器不能正常工作与SSL
My Google Maps Distance Finder Isnt Working Correctly With SSL
如果没有在IE中抛出关于SSL安全的错误,我似乎无法在SSL中正确工作。请帮助我,因为我不是很擅长Javascript。
<script src="//maps.google.com/maps?file=api&v=2&key=MY_API" type="text/javascript"></script>
<script type="text/javascript">
var geocoder, location1, location2, gDir;
function initialize() {
geocoder = new GClientGeocoder();
gDir = new GDirections();
GEvent.addListener(gDir, "load", function() {
var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
var shippingPrice = drivingDistanceMiles * 1.50;
document.getElementById('results').innerHTML = '<p><strong style="color:red;">Factory Address: </strong>' + location1.address + ' </p><p><strong style="color:red;">Your Address: </strong>' + location2.address + '</p><p><strong style="color:red;">Driving Distance: </strong>' + drivingDistanceMiles.toFixed(1) + ' miles </p><p><strong style="color:red;">Estimated Shipping Cost:</strong> $' + shippingPrice.toFixed(2) + ' USD';
});
}
function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first address");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(document.forms[0].address2.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the second address");
}
else
{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
gDir.load('from: ' + location1.address + ' to: ' + location2.address);
}
});
}
});
}
</script>
<body onload="initialize()">
<h3 style="color:red;">Estimate Your Shipping Cost</h3>
<form action="#" onsubmit="showLocation(); return false;">
<p style="color:white;">
<input type="text" name="address1" value="Douglas, GA" style="display:none" />
Enter Your Address:<br/>
<input type="text" name="address2" placeHolder="Your Address" />
<input type="submit" value="Search" />
</p>
</form>
<p id="results" style="color:white;"></p>
我的猜测是,它正在使用api的版本2,但我不知道如何改变这个
将<script src="//maps.google.com/maps?file=api&v=2&key=MY_API" type="text/javascript"></script>
改为<script src="https//maps.google.com/maps?file=api&v=2&key=MY_API" type="text/javascript"></script>
API的版本2只能由高级会员通过SSL访问。
版本3可以。
来源:http://code.google.com/apis/maps/faq.html#ssl (SSL部分的最后一节有您的确切错误)
相关文章:
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JavaScript打印功能使日历停止工作
- Javascript.getHours()工作不正常
- 为什么这在IE中的工作方式与在Firefox中不同
- 视频HTML没有'无法在Internet Explorer 11上工作
- 扩展移相器按钮类不工作
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 正在尝试使用if和else添加类,但无法正常工作
- Jquery FadeIn FadeOut 只工作一次
- Foreach无法在Typescript中工作
- Facebook javascript sdk在没有ssl的情况下工作
- 安装SSL后,某些脚本停止工作
- Jquery UIDialog无法在ssl页面上工作
- 当用户更改其系统日期时,由于SSL证书无效,JS无法工作
- 基本的带有SSL的Redbird反向代理不能在Ubuntu Server 14.04上工作
- 我的谷歌地图距离查找器不能正常工作与SSL