Hello,
had this code in v2023 on a list page that as a gmap object..
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
var myLatlng = new google.maps.LatLng(latitude, longitude);
const image = "images/mapiconscollection-markers/you-are-here-2.png";
var map = $("#mp_GOHERE_POILocations_id").data("map");
var marker = new google.maps.Marker({
position: myLatlng,
title: "Current Location",
icon: image,
});
marker.setMap(map);
map.setZoom(9);
map.setCenter(marker.getPosition());
});
} else {
altered the code to support the new AdvancedMarkerElement as:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
var myLatlng = new google.maps.LatLng(latitude, longitude);
var map = $("#mp_washrooms_id").data("map");
var marker = new google.maps.marker.AdvancedMarkerElement({
map,
position: { lat: latitude, lng: longitude },
title: "Current Location",
});
marker.setMap(map);
map.setZoom(9);
map.setCenter(marker.position);
});
} else {
the only quirk is the icon: image attribute is not valid to show our custom you are here... icon.
does anyone have a refernce to a replacement or usage
thanks,