Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5f861c5
Add my location button
nploi Dec 12, 2022
d9a4fa6
Move to current location when click
nploi Dec 13, 2022
1450b75
Add blue dot
nploi Dec 14, 2022
03ed666
Update my location icon
nploi Dec 14, 2022
72b6553
Add blue dot
nploi Dec 14, 2022
ea3dd73
Add animation
nploi Dec 19, 2022
64668d0
Update my location element
nploi Dec 19, 2022
e2a5a24
Update my location element
nploi Dec 19, 2022
1ae5172
Update my location element
nploi Dec 19, 2022
9abc526
Add blue dot
nploi Dec 19, 2022
b986d65
Add blue dot icon
nploi Dec 20, 2022
c358fe8
Format code
nploi Dec 20, 2022
278b043
Update UI
nploi Dec 20, 2022
a72e0a1
Update types
nploi Dec 20, 2022
7ad54b5
Revert code
nploi Dec 20, 2022
e0c6c3d
Revert code
nploi Dec 20, 2022
ea4cdef
Add integration test
nploi Dec 24, 2022
1cdce7a
Revert code
nploi Dec 24, 2022
58c74ec
Fix test fail
nploi Dec 25, 2022
7bd8aa4
Fix test fail
nploi Dec 25, 2022
1b62e8c
Add more test & fix test fail
nploi Dec 25, 2022
4d6ba54
Revert code
nploi Dec 25, 2022
9d40e2e
Fix spelling
nploi Dec 25, 2022
f3a8fc9
Updated version & changelog
nploi Dec 25, 2022
77414ec
Updated version & changelog
nploi Dec 25, 2022
6668606
Updated version & changelog
nploi Dec 25, 2022
1b4b0bb
Move code to separate file, update logic, add mylocation-sprite-2x to…
nploi Dec 28, 2022
241f69d
Update logic watch position and check permission
nploi Dec 31, 2022
c0fff06
Rename method
nploi Dec 31, 2022
1747092
Revert code
nploi Dec 31, 2022
dd51548
Fix unit-test & fix logic
nploi Jan 1, 2023
c99c506
Update blue dot icon & add todo me
nploi Jan 1, 2023
6c0aecd
Fix lint
nploi Jan 1, 2023
cbc6bc2
Add unit-test for location permission
nploi Jan 1, 2023
766d690
Add author
nploi Jan 1, 2023
d85e6b8
Fix error syntax
nploi Jan 1, 2023
f99bce4
Revert code
nploi Jan 1, 2023
9755380
Fix lint
nploi Jan 1, 2023
65630ef
Merge branch 'main' of https://github.com/nploi/plugins into impl-my-…
nploi Jan 11, 2023
42e307a
Fix linter
nploi Jan 11, 2023
0090120
Merge branch 'main' of https://github.com/nploi/plugins into impl-my-…
nploi Jan 23, 2023
3db8113
Merge branch 'main' into impl-my-location
nploi Jan 25, 2023
9270247
Fix linter
nploi Jan 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add blue dot
  • Loading branch information
nploi committed Dec 25, 2022
commit 1450b756fbdb18dc8bb0d5bd8a7bdf3d95381943
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,13 @@ class Page1 extends StatefulWidget {
class _Page1State extends State<Page1> {
@override
void initState() {
Timer time = Timer.periodic(Duration(seconds: 3), (Timer t) => timer());
super.initState();
}

LatLng _kMapCenter1 = LatLng(19.0182, 72.8479);
LatLng _kMapCenter2 = LatLng(19.0183, 72.8480);
bool toggle = false;

Future timer() async {
if (toggle) {
setState(() {
_kMapCenter1 = LatLng(19.0181, 72.8478);
_kMapCenter2 = LatLng(19.0184, 72.8481);
});
toggle = !toggle;
} else {
setState(() {
_kMapCenter1 = LatLng(19.0182, 72.8479);
_kMapCenter2 = LatLng(19.0183, 72.8480);
});
toggle = !toggle;
}

print(_kMapCenter1.longitude);
}

Completer<GoogleMapController> _controller = Completer();

static final CameraPosition _kGooglePlex = CameraPosition(
Expand All @@ -81,11 +62,6 @@ class _Page1State extends State<Page1> {
myLocationButtonEnabled: true,
myLocationEnabled: true,
),
floatingActionButton: FloatingActionButton.extended(
onPressed: _goToTheLake,
label: Text('To the lake!'),
icon: Icon(Icons.directions_boat),
),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ class GoogleMapController {

// Create the map...
final gmaps.GMap map = _createMap(_div, options);
if (_lastMapConfiguration.myLocationButtonEnabled!) {
final button = _addMyLocationButton();
map.controls![gmaps.ControlPosition.RIGHT_BOTTOM as int]?.push(button);
if (_lastMapConfiguration.myLocationButtonEnabled! &&
_lastMapConfiguration.myLocationEnabled!) {
map.controls![gmaps.ControlPosition.RIGHT_BOTTOM as int]
?.push(_addMyLocationButton());
}
_googleMap = map;

Expand All @@ -181,48 +182,77 @@ class GoogleMapController {
);

_setTrafficLayer(map, _lastMapConfiguration.trafficEnabled ?? false);

if (_lastMapConfiguration.myLocationEnabled!) {
_watchPositionAndAddBlueDot();
_moveToCurrentLocation();
}
}

HtmlElement _addMyLocationButton() {
final controlButton = document.createElement('button');

// // Set CSS for the control.
controlButton.style.border = "2px solid #fff";
controlButton.style.borderRadius = "3px";
controlButton.style.boxShadow = "0 2px 6px rgba(0,0,0,.3)";
controlButton.style.color = "rgb(25,25,25)";
controlButton.style.cursor = "pointer";
controlButton.style.fontFamily = "Roboto,Arial,sans-serif";
controlButton.style.fontSize = "16px";
controlButton.style.lineHeight = "38px";
controlButton.style.margin = "8px 0 22px";
controlButton.style.padding = "0 5px";
controlButton.style.textAlign = "center";
// controlButton.innerHtml = "&#xe55c;";
controlButton.text = "My Location";
controlButton.title = "Click to recenter the map";
// controlButton. = "button";
// Setup the click event listeners: simply set the map to Chicago.
// controlButton.style.border = "2px solid #fff";
// controlButton.style.borderRadius = "3px";
// controlButton.style.boxShadow = "0 2px 6px rgba(0,0,0,.3)";
// controlButton.style.color = "rgb(25,25,25)";
// controlButton.style.cursor = "pointer";
// controlButton.style.fontFamily = "Roboto,Arial,sans-serif";
// controlButton.style.fontSize = "16px";
// controlButton.style.lineHeight = "38px";
// controlButton.style.margin = "8px 0 22px";
// controlButton.style.padding = "0 5px";
// controlButton.style.textAlign = "center";
controlButton.className = "gm-control-active";
controlButton.innerHtml = "&#xe55c;";
// controlButton.title = "Click to recenter the map";
controlButton.addEventListener("click", ((event) {
window.navigator.geolocation.getCurrentPosition().then((value) {
moveCamera(
CameraUpdate.newLatLng(LatLng(
value.coords!.latitude!.toDouble(),
value.coords!.longitude!.toDouble(),
)),
);
});
_moveToCurrentLocation();
}));
// if (window.navigator.geolocation) {
// navigator.geolocation.getCurrentPosition(showPosition);
// }
// final centerControlDiv = document.createElement("div");
// Create the control.
// Append the control to the DIV.
// centerControlDiv.append(controlButton);
return controlButton as HtmlElement;
}

void _moveToCurrentLocation() {
window.navigator.geolocation.getCurrentPosition().then((location) {
moveCamera(
CameraUpdate.newLatLng(LatLng(
location.coords!.latitude!.toDouble(),
location.coords!.longitude!.toDouble(),
)),
);
});
}

void _watchPositionAndAddBlueDot() {
window.navigator.geolocation
.watchPosition()
.listen((Geoposition geolocation) {
_addBlueDot(geolocation);
});
}

void _addBlueDot(Geoposition geolocation) {
print('add blue dot');
assert(
_markersController != null, 'Cannot update circles after dispose().');
_circlesController?._addCircle(Circle(
circleId: CircleId('my_location_blue_dot'),
// scale: 10,
// fillOpacity: 1,
strokeWidth: 2,
radius: 50,
center: LatLng(
geolocation.coords!.latitude!.toDouble(),
geolocation.coords!.longitude!.toDouble(),
),

// strokeWidth: 2,
fillColor: Colors.blue,
strokeColor: Colors.white,
zIndex: -1,
));
}

// Funnels map gmap events into the plugin's stream controller.
void _attachMapEvents(gmaps.GMap map) {
map.onTilesloaded.first.then((void _) {
Expand Down

This file was deleted.