Android 用json加载标记

Android 用json加载标记,android,map,cordova,Android,Map,Cordova,我按照我的申请。反过来,我会在设备中获得空白,并且不会显示.Map 代码: <script type="text/javascript"> $(function() { $('#map_canvas').gmap().bind('init', function() { $.getJSON( 'http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx?latitude=&longitude=', function(data) {

我按照我的申请。反过来,我会在设备中获得空白,并且不会显示
.Map

代码:

<script type="text/javascript">
$(function() {
    $('#map_canvas').gmap().bind('init', function() {
        $.getJSON( 'http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx?latitude=&longitude=', function(data) {
            $.each( data.Status.Shoplist, function(i, m) {
                $('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(m.lat, m.lng)} );
            });
        });
    });
});
</script>
{"Status" :{ "Shoplist":[ { "id" : "1", "Name" : "ee", "phone" : "", "fax" : "",   "latitude" : "xxxxxx", "longitude" : "yyyyyyy" } , { "id" : "3", "Name" : "hhh", "phone" : "", "fax" : "",  "latitude" : "xxxx", "longitude" : "yyyyy" } ,..... } ]}}

确保在PhoneGap的白名单中添加了任何外部主机

在iOS中,根据本页的常见问题向PhoneGap.plist中的ExternalHosts键添加主机:

在Android中,将主机添加到项目中/res/xml中的phonegap.xml文件中。格式与iOS不同。下面是一个phonegap.xml文件示例:

<?xml version="1.0" encoding="utf-8"?>
<phonegap>
    <access origin="http://127.0.0.1*"/>
    <access origin="http://*.phonegap.com"/>
    <log level="DEBUG"/>
</phonegap>

如上面的示例所示,允许使用通配符


确保添加脚本可能尝试调用的任何外部主机(使用可以多种多样的谷歌地图)。当您试图让它工作时,您总是可以添加
*
以允许所有外部主机。

由于您的json没有lat或lng属性,您应该将addMarker方法中的代码更改为

新的google.maps.LatLng(米纬度,米经度)