谷歌地图在 IOS7 中崩溃 [英] Google Map crashes in IOS7

查看:35
本文介绍了谷歌地图在 IOS7 中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个混合应用程序,我们正在我们的应用程序中使用谷歌地图 API.当我们尝试在地图中加载 2000 个数据标记时,它崩溃了.地图在 IOS6、IOS5 中不会崩溃.它仅在 IOS7 中发生.是否对 ios7 应用程序进行了任何与内存相关的更改.

We are developing an Hybrid app and we are using google map API in our application. When we are trying to load 2000 data markers in the map, it got crashed. Map is not get crashed in IOS6, IOS5. It is happening only in IOS7. Is there any memory related change done for ios7 application.

推荐答案

如前所述,iOS7 对内存使用更为严格.Chrome等其他浏览器也会出现这种情况,所以当应用达到内存使用上限时,就会出现崩溃.

As said previously iOS7 is more strict with memory usage. This behavior occurs in other browsers like Chrome, so when an app reach upper limit in memory usage, the crash appears.

我仅使用 Gmaps javascript API 和 jQuery 隔离了两个测试用例:

I have isolated two test cases using only Gmaps javascript API and jQuery:

用 100 个标记进行测试:一切正常

Testing with 100 markers: Everything it's ok

http://jsfiddle.net/edfFq/6/embedded/result

使用 3000 个标记进行测试:发生崩溃

Testing with 3000 markers: Crash occurs

http://jsfiddle.net/edfFq/7/embedded/result/

$(document).ready(function () {
    var map;
    var centerPosition = new google.maps.LatLng(40.747688, -74.004142);


    var options = {
        zoom: 2,
        center: centerPosition,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map($('#map')[0], options);


    for (var i=0;i<2800;i++){        
      var position = new google.maps.LatLng(40*Math.random(),-74*Math.random());
      var marker = new google.maps.Marker({
            position: position,
            map: map           
        });
    }
});

如果您的地图使用标签、自定义图标和集群,您可以使用较少数量的标记来解决崩溃问题.

You can get the crash with a less number of markers if your map uses: labels, custom icons and clusters.

这篇关于谷歌地图在 IOS7 中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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