钛:如何在地图上显示多个注释? [英] Titanium: How to show multiple Annotations on Map?

查看:81
本文介绍了钛:如何在地图上显示多个注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Titanium SDK的第二天.

Its mine 2nd day on Titanium SDK.

我想在地图上显示多个注释.我已经在SO处提到了答案,但找不到解决方法!

I want to show multiple annotations on the map. I have referred answers at SO but couldn't find fix !

我尝试了以下代码:-

// To create map
var mapview = Titanium.Map.createView({
        mapType: Titanium.Map.STANDARD_TYPE,
        region:{latitude:33.74511, longitude:-84.38993, latitudeDelta:0.5, longitudeDelta:0.5},
        animate:true,
        regionFit:true,
        userLocation:true,
        annotations:[createAnnotations()],
        top:110,
        height:200
    });  

// CREATE ANNOTATIONS

function createAnnotations ()
{
    var annoatationData = [];
    for (var i=0; i < 10; i++) 
    {
            var mountainView = Titanium.Map.createAnnotation(
            {
                latitude:37.390749,
                longitude:-122.081651,
                title:"Appcelerator Headquarters",
                subtitle:'Mountain View, CA',
                pincolor: isAndroid ? "orange" : Titanium.Map.ANNOTATION_RED,
                animate:true,
                myid:i // CUSTOM ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
            });

      annoatationData.push(mountainView);
    };  

    return annoatationData ;
}

但是我收到此错误

[错误]传递给函数的类型无效.预期:NSDictionary,是: __NSArrayM在-[TiMapView注记来源Arg:](TiMapView.m:96)

[ERROR] Invalid type passed to function. expected: NSDictionary, was: __NSArrayM in -[TiMapView annotationFromArg:] (TiMapView.m:96)

有什么建议吗?

谢谢...

推荐答案

解决了!!!

只需替换此行代码即可:

Just replaced this line of code :

 annotations:[createAnnotations()],

 annotations:createAnnotations(),

这篇关于钛:如何在地图上显示多个注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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