【问题标题】:Appcelerator Ti.map selected annotation imageAppcelerator Ti.map 选定的注释图像
【发布时间】:2018-08-19 17:29:45
【问题描述】:

我正在使用 Appcelerator 上的 ti.map 模块,但似乎找不到任何解决方案来更改选择后的注释图像。如何做到这一点?

需要支持 iOS 和 Android 使用 Titanium SDK 7.2

【问题讨论】:

  • 你能告诉我们你用来尝试的代码吗?
  • 我真的没有任何代码,因为我不知道该怎么做。没有我可以设置的选定注释图像属性。现在我正在做的是删除注释并添加一个具有不同图像的新注释。然后,当他们选择其他东西时,我确实重新删除了旧的,删除了新选择的注释......非常复杂。不确定这样做的正确性是什么?

标签: android ios maps titanium appcelerator


【解决方案1】:

尝试使用自定义视图作为注解:

var myAnnotationView = Ti.UI.createView({
    backgroundImage: '/my_image.png',
});

var customAnnotation = map.createAnnotation({
   customView: myAnnotationView,
   latitude: lat,
   longitude: lon,
   title: 'My custom pin'
});

myAnnotationView.backgroundImage = '/my_image2.png';

【讨论】:

    【解决方案2】:

    使用自定义视图:

    var _costumView = Ti.UI.createView({
        backgroundImage: '/image1.png' }); 
    
    var _annotation = map.createAnnotation({
       customView: _costumView,
       latitude: _latitude,
       longitude: _longitude
    });
    
    _costumView.backgroundImage = '/image2.png';
    _annotation.customView = _costumView;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多