2017-02-27 65 views
0

我在nativescript中使用mapbox,我们如何向标记工具提示添加自定义视图(HTML或XML)。Nativescript mapbox自定义标记工具提示

标记只显示标题和副标题,我需要查看我自己的布局,而不是

map.addMarkers([{ 
    lat: 52.3602160, 
    lng: 4.8891680, 
    title: 'marker title', 
    subtitle: 'marker subtitle', 
    image: 'https://farm9.staticflickr.com/8571/15844010757_63b093d527_n.jpg' 
}]); 

回答

0

根据to the plugin README你可以添加你自己的标记图标通过图标iconPath

var onTap = function(marker) { 
    console.log("Marker tapped with title: '" + marker.title + "'"); 
    }; 
    var onCalloutTap = function(marker) { 
    alert("Marker callout tapped with title: '" + marker.title + "'"); 
    }; 

    mapbox.addMarkers([ 
    { 
     id: 2, // can be user in 'removeMarkers()' 
     lat: 52.3602160, // mandatory 
     lng: 4.8891680, // mandatory 
     title: 'One-line title here', // no popup unless set 
     subtitle: 'Infamous subtitle!', 
     icon: 'res://cool_marker', // preferred way, otherwise use: 
     icon: 'http(s)://website/coolimage.png', // from the internet (see the note at the bottom of this readme), or: 
     iconPath: 'res/markers/home_marker.png', 
     onTap: onTap, 
     onCalloutTap: onCalloutTap 
    }, 
    { 
     .. 
    } 
    ]) 

还有official demo演示如何使用标记图标