Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Finally got it working. This is for all those who still haven't found a solution. Below code adds offset to the markers on same location:</p> <p>In your <code>createMarker</code> function add this code:</p> <pre class="lang-js prettyprint-override"><code>//get array of markers currently in cluster var allMarkers = namespace.mapParams.mapMarkersArray; //final position for marker, could be updated if another marker already exists in same position var finalLatLng = latlng; //check to see if any of the existing markers match the latlng of the new marker if (allMarkers.length != 0) { for (i=0; i &lt; allMarkers.length; i++) { var existingMarker = allMarkers[i]; var pos = existingMarker.getPosition(); //if a marker already exists in the same position as this marker if (latlng.equals(pos)) { //update the position of the coincident marker by applying a small multipler to its coordinates var newLat = latlng.lat() + (Math.random() -.5) / 1500;// * (Math.random() * (max - min) + min); var newLng = latlng.lng() + (Math.random() -.5) / 1500;// * (Math.random() * (max - min) + min); finalLatLng = new google.maps.LatLng(newLat,newLng); } } } </code></pre> <p><s><a href="http://www.frontendfan.com/multiple-markers-with-the-exact-same-location/" rel="nofollow noreferrer">Refer this</a></s></p> <p>Now update your <code>google.maps.Marker</code> object for each marker with new position value – <code>finalLatLng</code>.</p> <pre class="lang-js prettyprint-override"><code>var marker = new google.maps.Marker({ map: msf_namespace.mapParams.resultmap, position: finalLatLng, title: name, icon: markericon }); //add each generated marker to mapMarkersArray namespace.mapParams.mapMarkersArray.push(marker); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload