iOS-Density-Map 0.1.2

iOS-Density-Map 0.1.2

Enrique Bermudez维护。



  • ebermudezcds

iOS Density Map

Version License Platform Build Status

通过使用OpenGL ES,iOS Density Map可以在地图上高效地渲染数千个粒子。

iOS Density Map有两个主要组件

GLParticlesRender:eaglcontext中渲染所有粒子。基本上,它用特定的样式(GLParticleStyle)渲染粒子组。

GLDensityMapView:GLParticlesRender提供eaglcontext和粒子组信息。为了显示粒子,GLDensityMapView提供了一些需要重写的属性和块。

安装

iOS-Density-Map通过CocoaPods提供。要安装它,只需将以下行添加到Podfile中

pod 'iOS-Density-Map'

然后导入GLDensityMap.h头文件

#import <GLDensityMap.h>

使用

- (void)setupDensityMapView{
    
    //Set the number of particles styles (style groups).
    self.densityMapView.styleGroupsCount = 1;
    
    //Returns the `GLParticleStyle` for each group.
    self.densityMapView.styleForStyleGroup = ^GLParticleStyle(GLStyleGroupIndex groupIndex) {
        GLParticleStyle style = {
            .radius = 7,
            .blurFactor = 0.95,
            .r = 255,
            .g = 130,
            .b = 0,
            .opacity = 0.45,
        };
        return style;
    };
    
    __weak ViewController *wself = self;
    
    //Returns the number of particles for each group.
    self.densityMapView.particlesCountForStyleGroup = ^uint(GLStyleGroupIndex groupIndex) {
        return (int)wself.locations.count;
    };
    
    //Retruns the x,y position for each particle
    self.densityMapView.positionForParticle = ^CGPoint(GLParticleIndex pointIndex, GLStyleGroupIndex groupIndex) {
        return  [wself.mapView convertCoordinate:wself.locations[pointIndex].coordinate
                                   toPointToView:wself.view];
    };
}

示例

作者

Enrique Bermúdez, [email protected]

许可协议

iOS 密度图采用 MIT 许可协议。请查阅 LICENSE 文件以获取更多信息。