nativescript-danem-google-maps-utils
为 iOS 和 Android 提供的 NativeScript Google Maps 工具库。
npm i --save nativescript-danem-google-maps-utils
- 版本:1.0.18
- GitHub: https://github.com/j20mc/Nativescript-Danem-Google-Maps-Utils
- NPM: https://npmjs.net.cn/package/nativescript-danem-google-maps-utils
- 下载量
- 昨天:0
- 上周:0
- 上个月:0
nativescript-danem-google-maps-utils (V1.0.17)
NativeScript Google Maps SDK 工具库,适用于 iOS 和 Android
- 实现聚类功能
- 实现热力图功能
*** 根据需要,我愿意改进此插件,因此请不要犹豫,提出请求! ***
依赖项
- nativescript-google-maps-sdk
- (Android - gradle) googlePlayServicesVersion = "17.0.0"
安装
tns plugin add nativescript-danem-google-maps-utils
用法
导入
var GoogleMaps = require('nativescript-google-maps-sdk');
var GoogleMapsUtils = require('nativescript-danem-google-maps-utils');
调用函数
// After initializing google maps and creating a marker array :
GoogleMapsUtils.setupMarkerCluster(mapView, makerSet);
GoogleMapsUtils.setupHeatmap(this.mapView, positionSet);
聚类信息
标记图标
var icon = 'marker_icon'
var marker: Marker = new Marker();
marker.infoWindowTemplate = icon;
makerSet.push(marker)
标记选择 & 聚类选择
onMarkerSelect(event) {
// Be careful, if you tap on a marker it returns a marker, if you tap on a cluster it returns an array of markers.
// var marker = event.marker
// or
// var arrayMarkers = event.marker
}
移动相机
GoogleMapsUtils.moveCamera(lat,lon,zoom)
清除
GoogleMapsUtils.clearMap();
GoogleMapsUtils.
热力图
generateRandomPosition(position, distance) {
var r = distance / 111300;
var x = position[0];
var y = position[1];
var u = Math.random();
var v = Math.random();
var w = r * Math.sqrt(u);
var t = 2 * Math.PI * v;
var dx = w * Math.cos(t) / Math.cos(y);
var xy = w * Math.sin(t);
return [x + dx, y + xy];
}
demoSetupHeatMap() {
var positionSet = [];
for (var i = 0; i < 400; i++) {
positionSet.push(this.generateRandomPosition([48.7797613, 2.4658653], 10000));
}
positionSet = positionSet.map(function (position) {
return GoogleMaps.Position.positionFromLatLng(position[0], position[1]);
});
GoogleMapsUtils.setupHeatmap(this.mapView, positionSet, [new Color("#00FF00"), new Color("#FF0000")], [0.10, 0.50]);
GoogleMapsUtils.setOpacity(0.8);
GoogleMapsUtils.setRadius(80)
}
设置不透明度 & 半径
GoogleMapsUtils.setOpacity(0.8);
GoogleMapsUtils.setRadius(80)
本插件受 nativescript-google-maps-utils 启发,感谢 @naderio