Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .babelrc
100644 → 100755
Empty file.
75 changes: 0 additions & 75 deletions .flowconfig

This file was deleted.

5 changes: 3 additions & 2 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# expo
.expo/
.expo/**/*


.idea/

generator-template-ballester.js

# dependencies
/node_modules
node_modules/**/*

# misc
.env.local
Expand Down
Empty file modified .watchmanconfig
100644 → 100755
Empty file.
Empty file modified App.js
100644 → 100755
Empty file.
9 changes: 0 additions & 9 deletions App.test.js

This file was deleted.

Empty file modified LICENSE
100644 → 100755
Empty file.
24 changes: 12 additions & 12 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# ReactNative Maps Clustering Example
# ReactNative Maps Clustering Example Expo App
In this branch you will find the Expo version of the demo app to showcase [react-native-maps-super-cluster](https://github.com/novalabio/react-native-maps-super-cluster), a high-performance map component with clustering for React Native, powered by [AirBnB's react-native-maps](https://github.com/airbnb/react-native-maps) and [MapBox's SuperCluster](https://github.com/mapbox/supercluster).

This is a showcase application for [react-native-maps-super-cluster](https://github.com/novalabio/react-native-maps-super-cluster), an high-performing map component with clustering for React Native, powered by [AirBnB's react-native-maps](https://github.com/airbnb/react-native-maps) and [MapBox's SuperCluster](https://github.com/mapbox/supercluster).
## Expo
You can test the app on your device with the Expo [demo app](https://exp.host/@mgscreativa/novalabreactnativemapsclusteringexample).

You can test the app in your device with the Expo [demo app](https://exp.host/@mgscreativa/novalabreactnativemapsclusteringexample).
[mgscreativa](https://github.com/mgscreativa) is maintaining this branch. This sample application was created with [CRNA](https://github.com/react-community/create-react-native-app).

## Running

```
npm i -g exp
npm i -g create-react-native-app

git clone https://github.com/novalabio/react-native-maps-super-cluster-example.git clusteredMap

Expand All @@ -19,15 +20,14 @@ npm start
```

## TODO
Check [master branch](https://github.com/novalabio/react-native-maps-super-cluster-example#todo).

* showcase `fitToElements` and `fitToRegion`
* showcase user-defined actions triggerable by a marker `onPress`
* showcase compatibility with existing `react-native-maps` features

# Contributors

* [Leonardo Lusoli](https://github.com/leolusoli)
# Contributors

* [Leonardo Lusoli](https://github.com/leolusoli)
* [Alberto Dallaporta](https://github.com/39otrebla)
* [Martin Briglia](https://github.com/mgscreativa)

# License
See [our License](https://github.com/novalabio/react-native-maps-super-cluster-example/blob/master/LICENSE) for more information.

22 changes: 22 additions & 0 deletions __tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'react-native';
import React from 'react';
import App from '../App';
import renderer from 'react-test-renderer';
import NavigationTestUtils from 'react-navigation/NavigationTestUtils';

describe('App snapshot', () => {
jest.useFakeTimers();
beforeEach(() => {
NavigationTestUtils.resetInternalState();
});

it('renders the loading screen', async () => {
const tree = renderer.create(<App />).toJSON();
expect(tree).toMatchSnapshot();
});

it('renders the root without loading screen', async () => {
const tree = renderer.create(<App skipLoadingScreen />).toJSON();
expect(tree).toMatchSnapshot();
});
});
11 changes: 9 additions & 2 deletions app.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
"description": "App to showcase markers clustering in React Native Maps using react-native-maps-super-cluster library. Git repo here https://github.com/novalabio/react-native-maps-super-cluster-example",
"slug": "novalabreactnativemapsclusteringexample",
"privacy": "public",
"sdkVersion": "23.0.0",
"sdkVersion": "30.0.0",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./app/assets/app-icons/ios-app-icon.png",
"splash": {
"image": "./app/assets/splash/splash-screen.png",
"resizeMode": "cover",
"backgroundColor": "#f1471d"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"bundleIdentifier": "com.mgscreativa.novalabreactnativemapsclusteringexample",
"icon": "./app/assets/app-icons/ios-app-icon.png"
"icon": "./app/assets/app-icons/ios-app-icon.png",
"supportsTablet": false
},
"android": {
"package": "com.mgscreativa.novalabreactnativemapsclusteringexample",
Expand Down
Empty file modified app/assets/app-icons/android-app-icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/assets/app-icons/ios-app-icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/assets/simbol.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified app/assets/splash/splash-screen.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 33 additions & 36 deletions app/helpers/generator.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,58 +1,55 @@
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @param {current} current Needs Definition in JSDoc.
* @return {array} Array of Objects with lat and lng attributes.
*/
export const generateRandomPoints = (center, radius, count, current) => {
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
export function generateRandomPoints(center, radius, count, current) {
const points = [];

for (let i = current; i < current + count; i++)
points.push({
id: `pin${i}`,
location: generateRandomPoint(center, radius),
location: generateRandomPoint(center, radius)
});

return points;
};
}

/**
* Generates number of random geolocation points given a center and a radius.
* Reference URL: http://goo.gl/KWcPE.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @return {Object} The generated random points as JS object with lat and lng attributes.
*/
export const generateRandomPoint = (center, radius) => {
const x0 = center.longitude;
const y0 = center.latitude;

* Generates number of random geolocation points given a center and a radius.
* Reference URL: http://goo.gl/KWcPE.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @return {Object} The generated random points as JS object with lat and lng attributes.
*/
export function generateRandomPoint(center, radius) {
var x0 = center.longitude;
var y0 = center.latitude;
// Convert Radius from meters to degrees.
const rd = radius / 111300;
var rd = radius / 111300;

const u = Math.random();
const v = Math.random();
var u = Math.random();
var v = Math.random();

const w = rd * Math.sqrt(u);
const t = 2 * Math.PI * v;
const x = w * Math.cos(t);
const y = w * Math.sin(t);
var w = rd * Math.sqrt(u);
var t = 2 * Math.PI * v;
var x = w * Math.cos(t);
var y = w * Math.sin(t);

const xp = x / Math.cos(y0);
var xp = x / Math.cos(y0);

// Resulting point.
return {
latitude: y + y0,
longitude: xp + x0,
longitude: xp + x0
};
};
}

// Usage Example.
// Generates 100 points that is in a 1km radius from the given lat and lng point.
// const randomGeoPoints = generateRandomPoints(
// { lat: 24.23, lng: 23.12 },
// 1000,
// 100,
// );
var randomGeoPoints = generateRandomPoints(
{ lat: 24.23, lng: 23.12 },
1000,
100
);
Loading