Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 4, 2021 02:39
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/2dfa28ff303a8348e82d233079064758 to your computer and use it in GitHub Desktop.
Save parzibyte/2dfa28ff303a8348e82d233079064758 to your computer and use it in GitHub Desktop.
if (!mapa) {
// Primera vez, lo creamos y centramos
mapa = new ol.Map({
target: 'mapa', // el id del elemento en donde se monta
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([longitude, latitude]),
zoom: ZOOM,
})
});
marcador = new ol.Feature({
geometry: new ol.geom.Point(
ol.proj.fromLonLat([longitude, latitude])
),
});
marcador.setStyle(new ol.style.Style({
image: new ol.style.Icon(({
src: icono,
scale: 0.5, // Aquí puedes ampliar o disminuir la imagen
})),
}));
const ultimaCapa = new ol.layer.Vector({
source: new ol.source.Vector({
features: [marcador],
}),
});
mapa.addLayer(ultimaCapa);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment