Skip to content

Instantly share code, notes, and snippets.

@fdansv
fdansv / Megaphone_.idea_.name
Created July 17, 2013 22:11
A real time web stats mobile n;tification thingy
Megaphone
public class CurrentLocationListener implements LocationListener{
public static double latitude;
public static double longitude;
@SuppressWarnings("static-access")
@Override
public void onLocationChanged(Location location) {
this.latitude=location.getLatitude();
this.longitude=location.getLongitude();
}
public class MapActivity extends SherlockActivity {
private LocationManager locationManager;
Location location;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
}
@fdansv
fdansv / gist:6579158
Last active December 23, 2015 04:19
Method that calculates the area of the polygon formed by the given list of Location objects
public double areaPoly(ArrayList<Location> places){
int[] x = new int[places.size()];
int[] y = new int[places.size()];
for (int i = 0; i<places.size(); i++){
x[i] = LocationToEN(places.get(i))[0];
y[i] = LocationToEN(places.get(i))[1];
}
double area = 0.0;
int j = x.length-1;
@fdansv
fdansv / SimpleMapBoxExample.java
Created October 23, 2013 01:03
MapBox Android simplest app
import com.mapbox.MapBoxView
public class SimpleMapBoxExample extends ApplicationContext {
MapBoxView map;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// We can initialize the map with the MapBox name, coordinates and zoom level
map = new MapBoxView("examples.map-9ijuk24y", 42.65742, 2.347682, 12);
@fdansv
fdansv / gist:7447669
Last active December 28, 2015 05:09
OSM + MapBox demo
import java.util.ArrayList;
import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.MapTileProviderBasic;
import org.osmdroid.tileprovider.tilesource.ITileSource;
import org.osmdroid.tileprovider.tilesource.XYTileSource;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
-4.454301595687866,
public static void main(String[] args) {
range(0, 100)
.mapToObj(i -> randomString(new Random(), 'A', 'Z', 10))
.sorted()
.collect(groupingBy(name -> name.charAt(0)))
.forEach((letter, names) -> System.out.println(letter + "\n\t" + names.stream().collect(joining("\n\t"))));
}
<html>
<link rel="stylesheet" href="vendor/leaflet.css" />
<style>
#map, html, body {
width: 100%; height: 100%; padding: 0; margin: 0;
}
</style>
<body>
<div id="map"></div>
<html>
<link rel="stylesheet" href="vendor/leaflet.css" />
<style>
#map, html, body {
width: 100%; height: 100%; padding: 0; margin: 0;
}
</style>
<body>
<div id="map"></div>