如何调用谷歌地图的地理$ C与jQuery阿贾克斯$ C服务 [英] How to call google map geocode service with jquery ajax

查看:168
本文介绍了如何调用谷歌地图的地理$ C与jQuery阿贾克斯$ C服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让经纬度从谷歌地图的地理code API。我的code是下面的地址值是纽约,纽约

I'm trying to get the LatLng from google map geocode api. my code is below with address values is "New York, NY"

$.ajax({
    url: 'http://maps.googleapis.com/maps/api/geocode/json',
    data: {
        sensor: false,
        address: address
    },
    success: function (data) {
        alert(data)
    }
});

但我没有得到警报中的任何值。

But I'm not getting any values in alert.

感谢您的帮助。

推荐答案

您需要联系的API有关的规则的。

You will need to contact the API regarding the rules.

$.getJSON( {
    url  : 'https://maps.googleapis.com/maps/api/geocode/json',
    data : {
        sensor  : false,
        address : address
    },
    success : function( data, textStatus ) {
        console.log( textStatus, data );
    }
} );

编辑:

怎么我的哑巴,不应该在计算器早晨!现在的问题是一个跨域请求。出于安全原因,这是不允许的。参见:<一href="http://stackoverflow.com/questions/2921745/how-to-make-cross-domain-ajax-calls-to-google-maps-api">How使跨域AJAX调用谷歌地图API?

How dumb of me, shouldn't be on stackoverflow in the morning! The problem is a cross-domain request. For security reasons this is not allowed. See: How to make cross-domain AJAX calls to Google Maps API?

请使用谷歌自己的天气预报客户端

这篇关于如何调用谷歌地图的地理$ C与jQuery阿贾克斯$ C服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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