1
一个谷歌的地方API搜索我试图让使用谷歌的地方API的地方在我的控制器:如何做angularjs控制器
$http.get("https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.503186,-0.126446&radius=5000&type=museum&key=MY_KEY")
.then(function(response) {
$scope.results = response.data;
console.log($scope.results);
});
可惜,这是行不通的。我的console.log后,我得到以下错误。
XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.503…126446&radius=5000&type=museum&key=MY_KEY. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9004' is therefore not allowed access.
顺便说一句,这不是唯一的本地主机,因为我已经尝试在一个活的服务器相同。 什么是谷歌angularjs的方式来实现这一目标?
你有没有简单地在你的index.html中添加谷歌地图文件与所有的JavaScript文件? –
是的,我的谷歌装载得很好。 –
以及为什么它们在Google链接和键= MY_KEY的末尾没有数字。你不想在这里发布它? –