Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyBusMap
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Sarukhanov
PyBusMap
Commits
c81f72b8
Commit
c81f72b8
authored
9 years ago
by
Anton Sarukhanov
Browse files
Options
Downloads
Patches
Plain Diff
Better view hash decoding (latlonzoom, stops, vehicles)
parent
5a5fe1e3
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Implemented Embed-code generator interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/js/map.js
+37
-16
37 additions, 16 deletions
static/js/map.js
with
37 additions
and
16 deletions
static/js/map.js
+
37
−
16
View file @
c81f72b8
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
var
BusMap
=
{
var
BusMap
=
{
cookiePrefix
:
"
BM_
"
,
cookiePrefix
:
"
BM_
"
,
zoomShowVehicles
:
15
,
zoomShowVehicles
:
15
,
vehicleZoom
:
16
,
stopZoom
:
16
,
vehicleMaxAge
:
10
,
vehicleMaxAge
:
10
,
};
};
...
@@ -305,15 +307,42 @@ BusMap.Map = function(opts) {
...
@@ -305,15 +307,42 @@ BusMap.Map = function(opts) {
+
that
.
leaflet
.
getZoom
();
+
that
.
leaflet
.
getZoom
();
return
view
;
return
view
;
}
}
function
applyViewString
(
view
)
{
if
(
!
view
||
view
==
""
)
return
false
;
if
(
view
.
charAt
(
0
)
==
"
s
"
)
return
_avsStop
(
view
);
if
(
view
.
charAt
(
0
)
==
"
v
"
)
return
_avsVehicle
(
view
);
window
.
location
.
replace
(
"
#
"
+
view
);
return
_avsLatLonZoom
(
view
);
function
_avsStop
(
view
)
{
if
(
!
that
.
stopMarkers
)
{
return
setTimeout
(
function
()
{
_avsStop
(
view
)
},
500
);
}
var
marker
=
that
.
stopMarkers
[
view
.
substring
(
1
)];
var
ll
=
marker
.
getLatLng
();
that
.
leaflet
.
setView
(
ll
,
that
.
stopZoom
);
marker
.
openPopup
();
}
function
_avsVehicle
(
view
)
{
if
(
!
that
.
vehicleMarkers
)
{
return
setTimeout
(
function
()
{
_avsVehicle
(
view
)
},
500
);
}
var
marker
=
that
.
vehicleMarkers
[
view
.
substring
(
1
)];
var
ll
=
marker
.
getLatLng
();
that
.
leaflet
.
setView
(
ll
,
that
.
vehicleZoom
);
marker
.
openPopup
();
}
function
_avsLatLonZoom
(
view
)
{
view
=
view
.
split
(
"
,
"
);
if
(
view
.
length
==
3
)
{
that
.
leaflet
.
setView
([
view
[
0
],
view
[
1
]],
view
[
2
]);
}
else
if
(
view
.
length
==
2
)
{
that
.
leaflet
.
setView
([
view
[
0
],
view
[
1
]]);
}
else
return
false
;
}
}
function
lastViewRecover
()
{
function
lastViewRecover
()
{
var
last
=
BusMap
.
getCookie
(
'
last_view
'
);
var
last
=
BusMap
.
getCookie
(
'
last_view
'
);
if
(
last
&&
last
!=
""
)
{
return
applyViewString
(
last
);
last
=
last
.
split
(
"
,
"
);
that
.
leaflet
.
setView
([
last
[
0
],
last
[
1
]],
last
[
2
]);
return
true
;
}
else
{
return
false
;
}
}
}
function
lastViewStore
()
{
function
lastViewStore
()
{
var
view
=
getViewString
();
var
view
=
getViewString
();
...
@@ -336,15 +365,7 @@ BusMap.Map = function(opts) {
...
@@ -336,15 +365,7 @@ BusMap.Map = function(opts) {
that
.
setViewFromUrlHash
=
function
()
{
that
.
setViewFromUrlHash
=
function
()
{
var
hash
=
window
.
location
.
hash
.
substring
(
1
);
var
hash
=
window
.
location
.
hash
.
substring
(
1
);
hash
=
hash
.
split
(
"
,
"
);
return
applyViewString
(
hash
);
if
(
hash
.
length
==
2
)
{
that
.
leaflet
.
setView
([
hash
[
0
],
hash
[
1
]]);
return
true
;
}
else
if
(
hash
.
length
==
3
)
{
that
.
leaflet
.
setView
([
hash
[
0
],
hash
[
1
]],
hash
[
2
]);
return
true
;
}
return
false
;
}
}
that
.
getUrlFromView
=
function
()
{
that
.
getUrlFromView
=
function
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment