Personal use ionic 2 beta in a project with ts, has the cordenadas of a point, I would like to know how I can do to put the map with the current position of the user and a marker in the saved coordinates. How can I do it ? Thanks
Personal use ionic 2 beta in a project with ts, has the cordenadas of a point, I would like to know how I can do to put the map with the current position of the user and a marker in the saved coordinates. How can I do it ? Thanks
To capture the user's current position you can use a plugin called Geolocation . To place multiple markers (assuming you have these positions in an array) you can place them by traversing the array and inserting on the map each array interaction:
let markers = arrayDePosicoes.forEach(item => {
//cria um objeto latLng a partir de coordenadas da posição atual do array
let currentPosition = new google.maps.LatLng(item.latitude,item.longitude);
//cria o marcador passando a coordenada e o elemento que contém o mapa
let marker = new google.maps.Marker({
position: currentPostition,
map: map,
title: 'Hello World!'
});
});
I think your question is very simple to solve. Create an object with the coordinates and pass this object to the options and then pass the options at the time of instantiating the map on the screen. This code works for me. Hope this helps!
let myPosition = { lat: -19.911911, lng: -43.917486}
let options = {
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: myPosition
};
let map = new google.maps.Map(document.getElementById("map"), options);