I am using angular google maps to display maps and markers. Is it possible to show the icon in the bottom right corner of the map that on click of it shows the current location.
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
<agm-marker *ngFor="let m of mapArrayList; let i = index"
[latitude]="m.geometry.location.lat()" [longitude]="m.geometry.location.lng()"
>
</agm-marker>
</agm-map>
First of all, Google Maps API v3 does not provide any default control for "show my location", so the only option would be implementing your own. But instead of creating it from scratch you could utilize a ready made control, e.g.
klokantech.GeolocationControl
Here is an instruction on how to integrate it into Angular 2+ application using Angular Google Maps:
1)load
maptilerlayer
library by putting it intoindex.html
:or dynamically, for example using
scriptjs
library:2)initialize
klokantech.GeolocationControl
in component:app.component.html:
app.component.js
Demo
Source code
Update
In case if you prefer to load
https://cdn.klokantech.com/maptilerlayer/v1/index.js
dynamically, below is provided the instruction how to perform it viascriptjs
package:Install the package:
and type definitions for
scriptjs
:Then import
$script.get()
method:and finally load library: