var timer;
var width = 1000,
height = 700,
radius = 325,
originalScale = height / 2,
scale = originalScale,
translation = [width / 2, height / 2],
scaleChange, rotation,
rotate = [100, -1],
velocity = [.009,.005],
time = Date.now();
var graticule = d3.geoGraticule();
var svg = d3.select('#map').append('svg').attr("id", "world").attr('width',width).attr('height',height).append('g');
var projection = d3.geoOrthographic().scale(radius).translate(translation).clipAngle(180);
var frontProjection = d3.geoOrthographic().scale(radius).translate(translation).clipAngle(90);
var path = d3.geoPath().projection(projection).pointRadius(1);
var frontPath = d3.geoPath().projection(frontProjection).pointRadius(1);
svg.append("circle").attr("cx", width/2).attr("cy", height/2).attr("r", radius).classed('cir', true);
d3.queue()
.defer(d3.csv, 'https://rawgit.com/Bramsiss/Globe/master/c.csv')
.defer(d3.json, 'https://rawgit.com/jonataswalker/map-utils/master/data/json/world-110m.json')
.await(load);
function load(error, cities, world ) {
if (error) { console.log(error); }
var land = topojson.feature(world, world.objects.land),
grid = graticule();
var outerArray = [];
cities.forEach(function(el) {
var innerArray = [+el.Longitude, +el.Latitude];
outerArray.push(innerArray);
});
var points = {
type: "MultiPoint",
coordinates: outerArray
};
var world = svg.selectAll('.lands').data([land]).enter().append('path').attr("class", "lands").attr('d', path);
var cities = svg.selectAll('.cities').data([points]).enter().append('path').attr("class","cities").attr('d', path);
d3.json("https://rawgit.com/Bramsiss/Globe/master/world-counries1.json", function(collection) {
var countries = svg.selectAll(".country").data(collection.features).enter().append("path").attr("d", path).attr("class", "country");
var frontCountries = svg.selectAll(".frontCountry")
.data(collection.features)
.enter().append("path")
.attr("d", frontPath)
.attr("class", "frontCountry")
.on("mouseover", function() {
this.style.stroke = 'rgba(193, 0, 32, 0.5)';
})
.on("mouseout", function() {
this.style.stroke = 'rgba(0, 0, 0, 0)';
});
var feature = svg.selectAll(".cities, .country, .lands");
var frontFeature = svg.selectAll(".frontCountry");
timer = d3.timer(function() {
var dt = Date.now() - time;
projection.rotate([rotate[0] + velocity[0] * dt, rotate[1] + velocity[1] * dt]);
feature.attr("d", path);
frontProjection.rotate([rotate[0] + velocity[0] * dt, rotate[1] + velocity[1] * dt]);
frontFeature.attr("d", frontPath);
function rot(dt) {
return
}
});
});
}
.country {
fill: transparent;
stroke: rgba(0, 0, 0, 0);
stroke-width: 2px;
}
.frontCountry {
fill: darkolivegreen;
fill-opacity: 0.6;
stroke: rgba(0, 0, 0, 0);
stroke-width: 2px;
}
.lands {
fill: transparent;
stroke: rgba(0, 0, 0, 1);
stroke-width: 1px;
}
.cities {
stroke: #2F4F4F;
stroke-width: 12px;
fill: black;
opacity: 0.8;
}
.cir {
fill:none;
stroke:black;
}
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<div id="map" text-align="center" style="width:100%; height:100%;">
<div id="globe"></div>
</div>