GUI - topo view: enhancements to allow scaling of bay area map.
Change-Id: Iabd50b529eb3f247463a71d29f7c447806c3afe7
Showing
3 changed files
with
24 additions
and
13 deletions
| ... | @@ -132,7 +132,7 @@ | ... | @@ -132,7 +132,7 @@ |
| 132 | mfs = settings.mapFillScale, | 132 | mfs = settings.mapFillScale, |
| 133 | path = d3.geo.path().projection(proj); | 133 | path = d3.geo.path().projection(proj); |
| 134 | 134 | ||
| 135 | - rescaleProjection(proj, mfs, dim, path, geoData); | 135 | + rescaleProjection(proj, mfs, dim, path, geoData, opts.adjustScale); |
| 136 | 136 | ||
| 137 | // return the results | 137 | // return the results |
| 138 | return { | 138 | return { |
| ... | @@ -142,7 +142,8 @@ | ... | @@ -142,7 +142,8 @@ |
| 142 | }; | 142 | }; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | - function rescaleProjection(proj, mfs, dim, path, geoData) { | 145 | + function rescaleProjection(proj, mfs, dim, path, geoData, adjustScale) { |
| 146 | + var adj = adjustScale || 1; | ||
| 146 | // adjust projection scale and translation to fill the view | 147 | // adjust projection scale and translation to fill the view |
| 147 | // with the map | 148 | // with the map |
| 148 | 149 | ||
| ... | @@ -161,7 +162,7 @@ | ... | @@ -161,7 +162,7 @@ |
| 161 | y = (y1 + y2) / 2; | 162 | y = (y1 + y2) / 2; |
| 162 | 163 | ||
| 163 | // size map to 95% of minimum dimension to fill space.. | 164 | // size map to 95% of minimum dimension to fill space.. |
| 164 | - var s = mfs / Math.min(dx / dim, dy / dim), | 165 | + var s = (mfs / Math.min(dx / dim, dy / dim)) * adj, |
| 165 | t = [dim / 2 - s * x, dim / 2 - s * y]; | 166 | t = [dim / 2 - s * x, dim / 2 - s * y]; |
| 166 | 167 | ||
| 167 | // set new scale, translation on the projection.. | 168 | // set new scale, translation on the projection.. | ... | ... |
| ... | @@ -56,11 +56,13 @@ | ... | @@ -56,11 +56,13 @@ |
| 56 | 56 | ||
| 57 | deferredProjection.resolve(gen.settings.projection); | 57 | deferredProjection.resolve(gen.settings.projection); |
| 58 | 58 | ||
| 59 | - mapLayer.selectAll('path') | 59 | + var path = mapLayer.selectAll('path') |
| 60 | .data(gen.geodata.features) | 60 | .data(gen.geodata.features) |
| 61 | .enter() | 61 | .enter() |
| 62 | .append('path') | 62 | .append('path') |
| 63 | .attr('d', gen.pathgen); | 63 | .attr('d', gen.pathgen); |
| 64 | + | ||
| 65 | + opts.fill && path.style('fill', opts.fill); | ||
| 64 | }); | 66 | }); |
| 65 | return deferredProjection.promise; | 67 | return deferredProjection.promise; |
| 66 | } | 68 | } | ... | ... |
| ... | @@ -347,24 +347,32 @@ | ... | @@ -347,24 +347,32 @@ |
| 347 | 347 | ||
| 348 | 348 | ||
| 349 | function setUpMap($loc) { | 349 | function setUpMap($loc) { |
| 350 | - var s1 = $loc.search().mapid, | 350 | + var qp = $loc.search(), |
| 351 | - s2 = ps.getPrefs('topo_mapid'), | 351 | + pr = ps.getPrefs('topo_mapid'), |
| 352 | - mapId = s1 || (s2 && s2.id) || 'usa', | 352 | + mi1 = qp.mapid, |
| 353 | + mi2 = pr && pr.id, | ||
| 354 | + mapId = mi1 || mi2 || 'usa', | ||
| 355 | + ms1 = qp.mapscale, | ||
| 356 | + ms2 = pr && pr.scale, | ||
| 357 | + mapScale = ms1 || ms2 || 1, | ||
| 353 | promise, | 358 | promise, |
| 354 | - cfilter, | 359 | + cfilter; |
| 355 | - opts; | ||
| 356 | 360 | ||
| 357 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); | 361 | mapG = zoomLayer.append('g').attr('id', 'topo-map'); |
| 358 | if (mapId === 'usa') { | 362 | if (mapId === 'usa') { |
| 359 | promise = ms.loadMapInto(mapG, '*continental_us'); | 363 | promise = ms.loadMapInto(mapG, '*continental_us'); |
| 360 | } else if (mapId === 'bayarea') { | 364 | } else if (mapId === 'bayarea') { |
| 361 | - promise = ms.loadMapInto(mapG, '*bayarea', {objectTag: 'bayareaGEO'}); | 365 | + // TODO: be consistent about propagating options to other cases |
| 366 | + promise = ms.loadMapInto(mapG, '*bayarea', { | ||
| 367 | + objectTag: 'bayareaGEO', | ||
| 368 | + adjustScale: mapScale, | ||
| 369 | + fill: 'aliceblue' | ||
| 370 | + }); | ||
| 362 | } else { | 371 | } else { |
| 363 | cfilter = countryFilters[mapId] || countryFilters.world; | 372 | cfilter = countryFilters[mapId] || countryFilters.world; |
| 364 | - opts = { countryFilter: cfilter }; | 373 | + promise = ms.loadMapRegionInto(mapG, { countryFilter: cfilter }); |
| 365 | - promise = ms.loadMapRegionInto(mapG, opts); | ||
| 366 | } | 374 | } |
| 367 | - ps.setPrefs('topo_mapid', {id:mapId}); | 375 | + ps.setPrefs('topo_mapid', { id: mapId, scale: mapScale }); |
| 368 | return promise; | 376 | return promise; |
| 369 | } | 377 | } |
| 370 | 378 | ... | ... |
-
Please register or login to post a comment