Skip to content

Commit

Permalink
Sets circle zIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
javierarce committed May 25, 2012
1 parent efcea08 commit 126a4ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions js/app.js
Expand Up @@ -438,7 +438,8 @@ $(function () {
var
solution_count = 0,
polygons = [],
agencies = [];
agencies = [],
zIndex = 0;

autocompleteSource = [];

Expand All @@ -459,12 +460,14 @@ $(function () {
view.coordinates[projectID] = [view.overlays[name][i][0][0].geojsonProperties.centroid_lat, view.overlays[name][i][0][0].geojsonProperties.centroid_lon];
}

zIndex += 10;

var
o = view.overlays[name][i][0][0],
properties = o.geojsonProperties,
cLatLng = new google.maps.LatLng(properties.centroid_lat, properties.centroid_lon),
rLatLng = new google.maps.LatLng(properties.radius_point_lat, properties.radius_point_lon),
distanceWidget = new RadiusWidget(map, cLatLng, rLatLng, view.overlays[name][i], [properties.agency_position]);
distanceWidget = new RadiusWidget(map, cLatLng, rLatLng, view.overlays[name][i], [properties.agency_position], zIndex);

if (name === 'projects') {
autocompleteSource.push({ circle: distanceWidget.circle, more: properties, value: properties.title, lat: properties.centroid_lat, lng: properties.centroid_lon});
Expand Down
8 changes: 4 additions & 4 deletions js/circle.js
Expand Up @@ -3,7 +3,7 @@
*
* @constructor
*/
function RadiusWidget(map, centroidCenter, radiusCenter, polygons, lines) {
function RadiusWidget(map, centroidCenter, radiusCenter, polygons, lines, zIndex) {

var
distance = this.distanceBetweenPoints(centroidCenter, radiusCenter),
Expand All @@ -22,10 +22,10 @@ function RadiusWidget(map, centroidCenter, radiusCenter, polygons, lines) {
center: centroidCenter,
radius: distance * 1000,
geodesic: true,
polygons: polygons
polygons: polygons,
zIndex:zIndex
});


// Draw line
var agency_lines = [];

Expand Down Expand Up @@ -64,7 +64,7 @@ function RadiusWidget(map, centroidCenter, radiusCenter, polygons, lines) {
title = properties.title,
approvalDate = properties.approval_date,
fixedApprovalDate = properties.approval_date,
moreURL = properties.external_project_url,
moreURL = config.MIF_URL + properties.nexso_code,

solutionName = properties.solution_name,
solutionURL = properties.solution_url,
Expand Down
7 changes: 4 additions & 3 deletions js/helpers.js
Expand Up @@ -10,7 +10,8 @@ var config = {
YEARS: [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014],
DATE_FORMAT: "yyyy-MM-dd",
DATE_SUFFIXES: ["th", "st", "nd", "rd"],
MIN_PROJECT_RADIUS: 100
MIN_PROJECT_RADIUS: 100,
MIF_URL: "http://www5.iadb.org/mif/ProgramsandProjects/ProjectsList/ProjectProfile/tabid/85/language/en-US/Default.aspx?prj="
};

config.START_YEAR = config.YEARS[0];
Expand Down Expand Up @@ -127,15 +128,15 @@ var queries = {
" " +
") " +
"SELECT " +
" nexso_code, solution_count, project_id, title, approval_date, fixed_approval_date, external_project_url, " +
" ST_Area(hull_geom), nexso_code, solution_count, project_id, title, approval_date, fixed_approval_date, external_project_url, " +
" location_verbatim, topic_name, budget, agency_name, agency_url, the_geom, agency_position, solution_id, solution_name, solution_url, " +
" ST_X(ST_Centroid(hull_geom)) AS centroid_lon, " +
" ST_Y(ST_Centroid(hull_geom)) AS centroid_lat, " +
" ST_X(ST_EndPoint(ST_LongestLine(ST_Centroid(hull_geom),hull_geom))) AS radius_point_lon, " +
" ST_Y(ST_EndPoint(ST_LongestLine(ST_Centroid(hull_geom), hull_geom))) AS radius_point_lat " +
"FROM qu " +
"ORDER BY " +
" ST_Area(hull_geom) desc"
" ST_Area(hull_geom) DESC"
};

String.prototype.splice = function( idx, rem, s ) {
Expand Down

0 comments on commit 126a4ad

Please sign in to comment.