[Resolved] Is there a way to add a marker without "click"
This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I have a location URL parameter which I wish to display as a marker without having take any user action
Expected the JS in comments to work, so I substituted the last 3-lines which also does not display a marker @ fixed location
URL, eg:
?marker=(41.85903463238362, -73.600231171875)
const queryString = window.location.search; // from hidden link
const urlParams = new URLSearchParams(queryString);
range = urlParams.get('maxrange'); // miles
if ( urlParams.has('marker') ) {thismarker = urlParams.get('marker');} // marker coordinates
thismarker = thismarker.replace('(', '');
thismarker = thismarker.replace(')', '');
var tmp = thismarker.split(", ");
console.log(queryString); console.log(thismarker); console.log(tmp[0]);console.log(tmp[1]);
// var myLatLng = { lat: tmp[0], lng: tmp[1] };
// var marker = new google.maps.Marker({
// position: myLatLng,
// title: 'Marker'
// map: map });
// marker.setMap(map);
I noticed that in your view "Pilots Marker view", you're already using the custom shortcodes "[marker_lat]" and "[marker_lon]" to get the latitude and longitude values from the URL parameter "marker".
I used the shortcode "wpv-map-marker" to add a new map marker, that uses "lat" and "lon" attributes to get values from these two custom shortcodes:
( screenshot: hidden link )
[wpv-map-marker map_id="map-8" marker_id="marker-from-url" marker_title="This is a marker title" lat="[marker_lat]" lon="[marker_lon]"]This is the content of the marker popup.[/wpv-map-marker]