Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fordecyt_2019
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rodrigo Tapia-McClung
fordecyt_2019
Commits
eaef7387
Commit
eaef7387
authored
Mar 11, 2021
by
Rodrigo Tapia-McClung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed map bounds and view. Fixed logic for clicking regions
parent
381c0f14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
centropais_periurbano.js
public/js/centropais_periurbano.js
+21
-24
No files found.
public/js/centropais_periurbano.js
View file @
eaef7387
...
@@ -20,8 +20,9 @@ let dateArray = [],
...
@@ -20,8 +20,9 @@ let dateArray = [],
timeLayer
,
timeLayer
,
layerControl
;
layerControl
;
let
isZoomed
=
undefined
,
let
bboxes
=
{},
bboxes
=
{};
previousClick
,
currentClick
;
const
baseUrl
=
new
URL
(
window
.
location
.
href
).
origin
;
// returns "http://localhost:8090"
const
baseUrl
=
new
URL
(
window
.
location
.
href
).
origin
;
// returns "http://localhost:8090"
// use `${baseUrl}/something`
// use `${baseUrl}/something`
...
@@ -86,13 +87,11 @@ const setupMap = (dates) => {
...
@@ -86,13 +87,11 @@ const setupMap = (dates) => {
attribution
:
"Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL."
attribution
:
"Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL."
});
});
//let bounds = cuencaBufferMask.getBounds();
let
southWest
=
L
.
latLng
(
19.65
,
-
103.10
),
let
southWest
=
L
.
latLng
(
19.87
,
-
102.87
),
northEast
=
L
.
latLng
(
22.65
,
-
99.12
),
northEast
=
L
.
latLng
(
23.02
,
-
99.31
),
bounds
=
L
.
latLngBounds
(
southWest
,
northEast
);
bounds
=
L
.
latLngBounds
(
southWest
,
northEast
);
map
=
L
.
map
(
"mexmap"
,
{
map
=
L
.
map
(
"mexmap"
,
{
//center: [17.22, -92.28],
minZoom
:
8
,
minZoom
:
8
,
zoom
:
6
,
zoom
:
6
,
attributionControl
:
false
,
attributionControl
:
false
,
...
@@ -128,7 +127,7 @@ const setupMap = (dates) => {
...
@@ -128,7 +127,7 @@ const setupMap = (dates) => {
scrollWheelZoom
:
true
,
scrollWheelZoom
:
true
,
attributionControl
:
false
,
attributionControl
:
false
,
zoomAnimation
:
true
zoomAnimation
:
true
}).
setView
([
16.96
,
-
92.97
],
8
);
}).
setView
([
21.15
,
-
100.94
],
8
);
cartoDarkLayerOverlay
.
addTo
(
overlay
);
cartoDarkLayerOverlay
.
addTo
(
overlay
);
L
.
control
.
attribution
({
position
:
"bottomright"
}).
addTo
(
overlay
);
L
.
control
.
attribution
({
position
:
"bottomright"
}).
addTo
(
overlay
);
...
@@ -255,26 +254,24 @@ const populateMap = async (mapData) => {
...
@@ -255,26 +254,24 @@ const populateMap = async (mapData) => {
let
region
=
feature
.
properties
.
Region
;
let
region
=
feature
.
properties
.
Region
;
// populate bboxes object
// populate bboxes object
bboxes
[
region
]
=
layer
.
getBounds
();
bboxes
[
region
]
=
layer
.
getBounds
();
// what to do when clicking on
polyg
ons
// what to do when clicking on
regi
ons
layer
.
on
(
"click"
,
()
=>
{
layer
.
on
(
"click"
,
()
=>
{
if
(
!
isZoomed
)
{
currentClick
=
region
;
if
(
currentClick
!=
previousClick
)
{
map
.
fitBounds
(
layer
.
getBounds
());
map
.
fitBounds
(
layer
.
getBounds
());
isZoomed
=
true
;
$
(
"#regionSelect"
).
val
(
region
).
change
();
$
(
'#regionSelect'
).
val
(
region
).
change
();
}
else
{
}
else
{
map
.
setView
([
16.96
,
-
92.97
],
8
)
map
.
setView
([
21.15
,
-
100.94
],
8
);
isZoomed
=
false
;
$
(
"#regionSelect"
)[
0
].
selectedIndex
=
0
;
$
(
'#regionSelect'
)[
0
].
selectedIndex
=
0
currentClick
=
undefined
;
}
}
// TODO: what to do if user clicks, pans, and then clicks another polygon
previousClick
=
currentClick
;
// right now it zooms out...
// need to check if clicked polygon is the same as before.
});
});
}
}
});
});
let
periurbanoBajio
=
omnivore
.
geojson
(
"data/periurbanoBajio.geojson"
,
null
,
periurbanoBajioLayer
)
let
periurbanoBajio
=
omnivore
.
geojson
(
"data/periurbanoBajio.geojson"
,
null
,
periurbanoBajioLayer
)
.
on
(
'ready'
,
()
=>
{
.
on
(
"ready"
,
()
=>
{
// populate combobox
// populate combobox
$
(
"#regionSelect"
).
append
(
"<option disabled value=
\"
0
\"
> -- Selecciona una región --</option>"
);
$
(
"#regionSelect"
).
append
(
"<option disabled value=
\"
0
\"
> -- Selecciona una región --</option>"
);
Object
.
keys
(
bboxes
).
forEach
(
region
=>
{
Object
.
keys
(
bboxes
).
forEach
(
region
=>
{
...
@@ -286,7 +283,7 @@ const populateMap = async (mapData) => {
...
@@ -286,7 +283,7 @@ const populateMap = async (mapData) => {
$
(
"#regionSelect"
).
on
(
"change"
,
()
=>
{
$
(
"#regionSelect"
).
on
(
"change"
,
()
=>
{
let
region
=
$
(
"#regionSelect"
).
val
();
let
region
=
$
(
"#regionSelect"
).
val
();
map
.
fitBounds
(
bboxes
[
region
]);
map
.
fitBounds
(
bboxes
[
region
]);
isZoomed
=
true
;
previousClick
=
region
;
});
});
});
});
periurbanoBajio
.
addTo
(
map
);
periurbanoBajio
.
addTo
(
map
);
...
@@ -321,7 +318,7 @@ const populateMap = async (mapData) => {
...
@@ -321,7 +318,7 @@ const populateMap = async (mapData) => {
if
(
layer
==
userFiles
[
0
])
{
if
(
layer
==
userFiles
[
0
])
{
glmap
.
getMapboxMap
().
setPaintProperty
(
layer
,
"fill-opacity"
,
0.7
);
glmap
.
getMapboxMap
().
setPaintProperty
(
layer
,
"fill-opacity"
,
0.7
);
}
}
})
})
;
/* glmap.getMapboxMap().addSource("munisLayer", {
/* glmap.getMapboxMap().addSource("munisLayer", {
//type: "vector",
//type: "vector",
...
@@ -350,9 +347,9 @@ const populateMap = async (mapData) => {
...
@@ -350,9 +347,9 @@ const populateMap = async (mapData) => {
"line-color": "grey",
"line-color": "grey",
"line-width": 5,
"line-width": 5,
},
},
'layout'
: {
"layout"
: {
'line-join': 'round'
,
"line-join": "round"
,
'line-cap': 'round'
"line-cap": "round"
},
},
});
});
*/
*/
...
@@ -516,7 +513,7 @@ L.TimeDimension.Layer.Tile = L.TimeDimension.Layer.extend({
...
@@ -516,7 +513,7 @@ L.TimeDimension.Layer.Tile = L.TimeDimension.Layer.extend({
}
else
{
}
else
{
glmap
.
getMapboxMap
().
setPaintProperty
(
layer
,
"fill-opacity"
,
0.7
);
glmap
.
getMapboxMap
().
setPaintProperty
(
layer
,
"fill-opacity"
,
0.7
);
}
}
})
})
;
}
}
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment