谷歌地图API的工作在本地主机,但在Web服务器不工作 [英] google maps api works at localhost but doesn't work at web server

查看:574
本文介绍了谷歌地图API的工作在本地主机,但在Web服务器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌地图API在地图上选择一些问题,并找到最短行驶路线。

I used google maps api for selecting some points on map and find to shortest driving route.

万物工作在本地主机,但是当我发布并上传服务器,它不工作...

Everythings works in localhost, but when i publish and upload it server, it doesn't work...

它为什么会发生?没有任何错误。地图即将页面上,但我不能看到标记和directionResult不加载的结果。这是关于授权?我有有效的帐户和API密钥等,并允许我我的域名的引用者。

Why it's happen? There isn't any error. Map is coming on page but i can't see markers and directionResult doesn't load the result. Is it about authorization? I have valid account and api key etc. And i allowed referer of my domain.

编辑:我请与克罗姆JS调试器的脚本。这里没有响应;

I check the script with crome JS debugger. There is no response here;

directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) 
{
    directionsDisplay.setDirections(response);    }
});

状态返回OK,在现场服务器,而不是价值。在本地主机它的工作!任何人都知道什么原因呢?

status returning "" value at live server, not "OK". In localhost its working! Anybody knows whats the reason?

您可以看到这里google.maps.api的例子;查看源代码:<一href=\"https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-simple\" rel=\"nofollow\">https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-simple

You can see the example of google.maps.api here; view-source:https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-simple

感谢您的帮助。

推荐答案

我解决了这个问题。其对Web服务器的小数点符号。在我的本地我使用。作为小数点符号。但是,在Web服务器,这是,因此在谷歌地图,纬度和郎点有错误的价值观和地图API无法找到点。

I solved the problem. Its about decimal symbol of web server. In my localhost i'm using "." as decimal symbol. But in web server it was "," so in google maps, lat and lang points have wrong values and maps api couldnt find the points.

改变Web服务器小数点符号从区域和语言设置(所有用户)之后。它开始工作......

After changing web servers decimal symbol from Regional And Language Settings(for all users). Its start to work...

这篇关于谷歌地图API的工作在本地主机,但在Web服务器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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