Add label to rider markers. #270
This commit is contained in:
parent
c05921cdf7
commit
f5606d83c0
3 changed files with 16 additions and 4 deletions
|
|
@ -37,8 +37,9 @@ class HomeController extends Controller
|
||||||
$long = $coordinates->getLongitude();
|
$long = $coordinates->getLongitude();
|
||||||
$lat = $coordinates->getLatitude();
|
$lat = $coordinates->getLatitude();
|
||||||
|
|
||||||
// use rider id as key
|
// use rider map label as key
|
||||||
$locations[$rider_id] = array($lat, $long);
|
$rider_map_label = $rider->getMapLabel();
|
||||||
|
$locations[$rider_map_label] = array($lat, $long);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -319,4 +319,10 @@ class Rider
|
||||||
{
|
{
|
||||||
return $this->sessions;
|
return $this->sessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMapLabel()
|
||||||
|
{
|
||||||
|
$map_label = $this->id . '-' . $this->first_name .' ' . $this->last_name;
|
||||||
|
return $map_label;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,14 @@ function initMap() {
|
||||||
displayMarkers();
|
displayMarkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMarker(location) {
|
function addMarker(rider_id, location) {
|
||||||
var marker = new google.maps.Marker({
|
var marker = new google.maps.Marker({
|
||||||
position: location,
|
position: location,
|
||||||
|
label: {
|
||||||
|
text: rider_id,
|
||||||
|
color: 'black',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
map: map
|
map: map
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -107,7 +112,7 @@ function displayMarkers() {
|
||||||
lng: long
|
lng: long
|
||||||
};
|
};
|
||||||
|
|
||||||
addMarker(location);
|
addMarker(rider_id, location);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue