Problem: I would like to draw a line connecting multiple Markers on a Google Map.
Solution: Add custom JavaScript to Layouts CSS & JS, or to a View's Search and Pagination JS panel:
jQuery(document).ready(function($){ function initMap() { var mapid = 'map-2'; var map = WPViews.view_addon_maps.get_map(mapid); var markers = WPViews.view_addon_maps.markers[mapid]; if(markers.length == 0) return; var tripCoordinates = []; var latLng; // loop over all the markers and create an array of lat lng objects for(var marker in markers){ latLng = { 'lat':markers[marker].position.lat(), 'lng':markers[marker].position.lng() }; tripCoordinates.push(latLng); } // create a new polyline using the coordinates array, and add it to the map var tripPath = new google.maps.Polyline({ path: tripCoordinates, geodesic: true, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 2 }); tripPath.setMap(map); } $( document ).on('js_event_wpv_addon_maps_init_map_completed', function( event, event_settings ) { initMap(); } ); } );
Relevant Documentation:
https://developers.google.com/maps/documentation/javascript/examples/polyline-simple
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.
This topic is split from https://toolset.com/forums/topic/the-installation-is-stopped-to-configuring-the-site/
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 6 replies, has 3 voices.
Last updated by 6 years, 5 months ago.
Assisted by: Christian Cox.