问题
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...
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.
Edit: 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); }
});
status returning "" value at live server, not "OK". In localhost its working! Anybody knows whats the reason?
You can see the example of google.maps.api here; view-source:https://google-developers.appspot.com/maps/documentation/javascript/examples/directions-simple
Thanks for any help.
回答1:
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.
After changing web servers decimal symbol from Regional And Language Settings(for all users). Its start to work...
回答2:
Recently I had the same problem.
After creating my api key it started working on my server too.
The weird fact is that locally always worked perfectly, no keys needed.
来源:https://stackoverflow.com/questions/14603936/google-maps-api-works-at-localhost-but-doesnt-work-at-web-server