简体   繁体   English

使用sencha touch的Google地图出现问题

[英]Having issues with google maps using sencha touch

I am new to sencha touch but the error I am getting seems to be related to google maps api. 我是sencha touch的新手,但我遇到的错误似乎与google maps api有关。 I am making a call to google maps api to search for aa specific place in sencha touch. 我正在打电话给Google Maps API,以在sencha touch中搜索特定位置。 But I am getting below error 但是我正在错误以下

在此处输入图片说明

Here is my code inside store/Places.js file 这是我在store / Places.js文件中的代码

Ext.define('TestIOS.store.Places', {
extend: 'Ext.data.Store',
config: {
    model: 'TestIOS.model.Place',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        url: 'https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AIzaSyCFWZSKDslql5GZR0OJlVcgoQJP1UKgZ5U',
        reader: {
            type: 'json',
            rootProperty: 'results'
        }
    }
}
});

How can I solve this error? 我该如何解决这个错误?

It is due to Same Origin Policy so to get the data from other servers we have to use JSONP But it seems that the latest version of the Google Maps API (v3) does not support jsonp . 这是由于Same Origin Policy所致,因此要从其他服务器获取数据,我们必须使用JSONP,但是最新版本的Google Maps API(v3)似乎不支持jsonp As a result, if you want to geocode, you're going to need to use the maps api: 因此,如果要进行地理编码,则需要使用maps api:

include 包括

<script src="http://maps.google.com/maps/api/js?sensor=false"></script>

in index.html before adding sencha microloader 在index.html中添加sencha microloader之前

<script id="microloader" type="text/javascript" src="sdk/microloader/development.js"></script>

and to get any address use google geocoder EX: 并使用Google geocoder EX获取任何地址:

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode( {'address': name of location },
        function(results, status) { console.log(results[0].geometry.location); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM