<view class="map">
<map id="map" longitude="{{ longitude }}" latitude="{{ latitude }}" scale="14" show-location
markers="{{markers}}"></map>
</view>
页面
getNearUsers(){
db.collection('users').where({
location: _.geoNear({
geometry: db.Geo.Point(this.data.longitude, this.data.latitude),
minDistance: 0,
maxDistance: 5000
}),
isLocation : true
}).field({
longitude : true,
latitude : true,
userPhoto : true
}).get().then((res)=>{
// console.log( res.data );
let data = res.data;
let result = [];
if( data.length ){
for( let i =0; i< data.length; i++ ){
result.push({
iconpath: data[i].userPhoto ,
id : data[i]._id,
latitude:data[i].latitude,
longitude:data[i].longitude,
width : 30,
height : 30
});
}
this.setData({
markers : result
});
}
});
}
js
[/__pageframe__/pages/near/near] marker id should be a number
这是警告