react-city-space-mapbox
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1313,3 +1313,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.map(function (d) { | ||
cityGeoJson.features.forEach(function (d) { | ||
var newColorTarget = colorMap.find(function (c) { | ||
@@ -1322,3 +1322,3 @@ return c.id.toString() === d.properties.id.toString(); | ||
}); | ||
cityUMapJson.features.map(function (d) { | ||
cityUMapJson.features.forEach(function (d) { | ||
var newColorTarget = colorMap.find(function (c) { | ||
@@ -1339,2 +1339,43 @@ return c.id.toString() === d.properties.id.toString(); | ||
var changeOpacity = function changeOpacity(input) { | ||
var map = input.map, | ||
sourceId = input.sourceId, | ||
minMaxPopulation = input.minMaxPopulation, | ||
minMaxGdpPppPc = input.minMaxGdpPppPc, | ||
regions = input.regions, | ||
mode = input.mode; | ||
var minPop = minMaxPopulation[0], | ||
maxPop = minMaxPopulation[1]; | ||
var minGdpPppPc = minMaxGdpPppPc[0], | ||
maxGdpPppPc = minMaxGdpPppPc[1]; | ||
var cityGeoJson = input.cityGeoJson; | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.forEach(function (d) { | ||
if (!isNaN(d.properties.population) && !isNaN(d.properties.gdpPpp)) { | ||
var population = d.properties.population; | ||
var gdpPppPc = d.properties.gdpPpp / population; | ||
var opacity = population >= minPop && population <= maxPop && gdpPppPc >= minGdpPppPc && gdpPppPc <= maxGdpPppPc && (!regions.length || d.properties.region !== null && regions.includes(d.properties.region.toString())) ? 1 : 0; | ||
d.properties = _extends({}, d.properties, { | ||
opacity: opacity | ||
}); | ||
} | ||
}); | ||
cityUMapJson.features.forEach(function (d) { | ||
if (!isNaN(d.properties.population) && !isNaN(d.properties.gdpPpp)) { | ||
var population = d.properties.population; | ||
var gdpPppPc = d.properties.gdpPpp / population; | ||
var opacity = population >= minPop && population <= maxPop && gdpPppPc >= minGdpPppPc && gdpPppPc <= maxGdpPppPc && (!regions.length || d.properties.region !== null && regions.includes(d.properties.region.toString())) ? 1 : 0; | ||
d.properties = _extends({}, d.properties, { | ||
opacity: opacity | ||
}); | ||
} | ||
}); | ||
var source = map.getSource(sourceId); | ||
if (source) { | ||
var data = mode === exports.MapMode.UMAP ? cityUMapJson : cityGeoJson; | ||
source.setData(_extends({}, data)); | ||
} | ||
}; | ||
var changeNodeSizing = function changeNodeSizing(input) { | ||
@@ -1348,3 +1389,3 @@ var map = input.map, | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.map(function (d) { | ||
cityGeoJson.features.forEach(function (d) { | ||
var newRadiusTarget = radiusMap.find(function (c) { | ||
@@ -1357,3 +1398,3 @@ return c.id.toString() === d.properties.id.toString(); | ||
}); | ||
cityUMapJson.features.map(function (d) { | ||
cityUMapJson.features.forEach(function (d) { | ||
var newRadiusTarget = radiusMap.find(function (c) { | ||
@@ -1453,3 +1494,4 @@ return c.id.toString() === d.properties.id.toString(); | ||
'circle-radius': ['interpolate', ['linear'], ['zoom'], 0, ['/', ['get', 'radius'], 12], 22, ['/', ['get', 'radius'], 1.25]], | ||
'circle-color': ['get', 'fill'] | ||
'circle-color': ['get', 'fill'], | ||
'circle-opacity': ['get', 'opacity'] | ||
} | ||
@@ -1619,2 +1661,15 @@ }); | ||
var setFilterParamaters = function setFilterParamaters(minMaxPopulation, minMaxGdpPppPc, regions) { | ||
changeOpacity({ | ||
sourceId: cityNodesSourceId, | ||
map: map, | ||
mode: mode, | ||
cityGeoJson: cityGeoJson, | ||
cityUMapJson: cityUMapJson, | ||
minMaxPopulation: minMaxPopulation, | ||
minMaxGdpPppPc: minMaxGdpPppPc, | ||
regions: regions | ||
}); | ||
}; | ||
return { | ||
@@ -1627,3 +1682,4 @@ map: map, | ||
setHighlighted: setHighlighted, | ||
setNodeSizing: setNodeSizing | ||
setNodeSizing: setNodeSizing, | ||
setFilterParamaters: setFilterParamaters | ||
}; | ||
@@ -1630,0 +1686,0 @@ }; |
@@ -1312,3 +1312,3 @@ import 'mapbox-gl/dist/mapbox-gl.css'; | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.map(function (d) { | ||
cityGeoJson.features.forEach(function (d) { | ||
var newColorTarget = colorMap.find(function (c) { | ||
@@ -1321,3 +1321,3 @@ return c.id.toString() === d.properties.id.toString(); | ||
}); | ||
cityUMapJson.features.map(function (d) { | ||
cityUMapJson.features.forEach(function (d) { | ||
var newColorTarget = colorMap.find(function (c) { | ||
@@ -1338,2 +1338,43 @@ return c.id.toString() === d.properties.id.toString(); | ||
var changeOpacity = function changeOpacity(input) { | ||
var map = input.map, | ||
sourceId = input.sourceId, | ||
minMaxPopulation = input.minMaxPopulation, | ||
minMaxGdpPppPc = input.minMaxGdpPppPc, | ||
regions = input.regions, | ||
mode = input.mode; | ||
var minPop = minMaxPopulation[0], | ||
maxPop = minMaxPopulation[1]; | ||
var minGdpPppPc = minMaxGdpPppPc[0], | ||
maxGdpPppPc = minMaxGdpPppPc[1]; | ||
var cityGeoJson = input.cityGeoJson; | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.forEach(function (d) { | ||
if (!isNaN(d.properties.population) && !isNaN(d.properties.gdpPpp)) { | ||
var population = d.properties.population; | ||
var gdpPppPc = d.properties.gdpPpp / population; | ||
var opacity = population >= minPop && population <= maxPop && gdpPppPc >= minGdpPppPc && gdpPppPc <= maxGdpPppPc && (!regions.length || d.properties.region !== null && regions.includes(d.properties.region.toString())) ? 1 : 0; | ||
d.properties = _extends({}, d.properties, { | ||
opacity: opacity | ||
}); | ||
} | ||
}); | ||
cityUMapJson.features.forEach(function (d) { | ||
if (!isNaN(d.properties.population) && !isNaN(d.properties.gdpPpp)) { | ||
var population = d.properties.population; | ||
var gdpPppPc = d.properties.gdpPpp / population; | ||
var opacity = population >= minPop && population <= maxPop && gdpPppPc >= minGdpPppPc && gdpPppPc <= maxGdpPppPc && (!regions.length || d.properties.region !== null && regions.includes(d.properties.region.toString())) ? 1 : 0; | ||
d.properties = _extends({}, d.properties, { | ||
opacity: opacity | ||
}); | ||
} | ||
}); | ||
var source = map.getSource(sourceId); | ||
if (source) { | ||
var data = mode === MapMode.UMAP ? cityUMapJson : cityGeoJson; | ||
source.setData(_extends({}, data)); | ||
} | ||
}; | ||
var changeNodeSizing = function changeNodeSizing(input) { | ||
@@ -1347,3 +1388,3 @@ var map = input.map, | ||
var cityUMapJson = input.cityUMapJson; | ||
cityGeoJson.features.map(function (d) { | ||
cityGeoJson.features.forEach(function (d) { | ||
var newRadiusTarget = radiusMap.find(function (c) { | ||
@@ -1356,3 +1397,3 @@ return c.id.toString() === d.properties.id.toString(); | ||
}); | ||
cityUMapJson.features.map(function (d) { | ||
cityUMapJson.features.forEach(function (d) { | ||
var newRadiusTarget = radiusMap.find(function (c) { | ||
@@ -1452,3 +1493,4 @@ return c.id.toString() === d.properties.id.toString(); | ||
'circle-radius': ['interpolate', ['linear'], ['zoom'], 0, ['/', ['get', 'radius'], 12], 22, ['/', ['get', 'radius'], 1.25]], | ||
'circle-color': ['get', 'fill'] | ||
'circle-color': ['get', 'fill'], | ||
'circle-opacity': ['get', 'opacity'] | ||
} | ||
@@ -1618,2 +1660,15 @@ }); | ||
var setFilterParamaters = function setFilterParamaters(minMaxPopulation, minMaxGdpPppPc, regions) { | ||
changeOpacity({ | ||
sourceId: cityNodesSourceId, | ||
map: map, | ||
mode: mode, | ||
cityGeoJson: cityGeoJson, | ||
cityUMapJson: cityUMapJson, | ||
minMaxPopulation: minMaxPopulation, | ||
minMaxGdpPppPc: minMaxGdpPppPc, | ||
regions: regions | ||
}); | ||
}; | ||
return { | ||
@@ -1626,3 +1681,4 @@ map: map, | ||
setHighlighted: setHighlighted, | ||
setNodeSizing: setNodeSizing | ||
setNodeSizing: setNodeSizing, | ||
setFilterParamaters: setFilterParamaters | ||
}; | ||
@@ -1629,0 +1685,0 @@ }; |
@@ -30,4 +30,5 @@ import mapboxgl from 'mapbox-gl'; | ||
setHighlighted: (id: number | string | null) => void; | ||
setFilterParamaters: (minMaxPopulation: [number, number], minMaxGdpPppPc: [number, number], regions: string[]) => void; | ||
} | ||
declare const initMap: (input: Input) => Output; | ||
export default initMap; |
{ | ||
"name": "react-city-space-mapbox", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Visualize the City Space using Mapbox", | ||
@@ -5,0 +5,0 @@ "author": "wsoeltz", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
430289
27
3527