Skip Navigation

[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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by lesT 2 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2157243
toolset b.png
toolset a.png

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);

const bangalore = { lat: 12.97, lng: 77.59 };
addMarker(bangalore, map);
marker.setMap(map);

#2157927

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot and suggest the best way to achieve this, I'll need to see exactly how and where you're planning to show this dynamic map marker.

Can you please share temporary admin login details, along with the link to an example page with the map?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#2162183

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

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]

You can read more about all the supported attributes for the "wpv-map-marker" shortcode at:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

#2162395

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.