Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 27, 2019 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/28e289e3ca96ded564a54c8c10897d2e to your computer and use it in GitHub Desktop.
Save parzibyte/28e289e3ca96ded564a54c8c10897d2e to your computer and use it in GitHub Desktop.
let marcador = new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([-99.12105, 19.419617])// En dónde se va a ubicar
),
});
// Agregamos icono
marcador.setStyle(new ol.style.Style({
image: new ol.style.Icon({
src: "pizza.png",
})
}));
// marcadores debe ser un arreglo
const marcadores = []; // Arreglo para que se puedan agregar otros más tarde
marcadores.push(marcador);// Agregamos el marcador al arreglo
let capa = new ol.layer.Vector({
source: new ol.source.Vector({
features: marcadores, // A la capa le ponemos los marcadores
}),
});
// Y agregamos la capa al mapa
mapa.addLayer(capa);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment