locked
Google maps market cluser question?? RRS feed

  • Question

  • User-631683198 posted

    hi,

    I am using google maps on my site to show location of customers.

    If you hover over a marker it opens a window with an image and a optional link to another page.

    this works well on desktop but on mobile device when you hover the window it goes directly

    to the other page that is linked  without first presenting window to the user.

    Is there any reason for this. Perhaps I missing something?

        
    
         <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    
    
    <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.12/src/markerclusterer_packed.js">  </script>
    
    
    
    
    
    
    
    
    
        <script type="text/javascript">
    
    
    
    
            function initialize() {
                var markers = JSON.parse('<%=ConvertDataTabletoString() %>');
                var mapOptions = {
                    center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
                    zoom: 5,
                    maxZoom: 12,
    
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                    //  marker:true
                };
    
    
                var infoWindow = new google.maps.InfoWindow();
    
    
                var latlngbounds = new google.maps.LatLngBounds();
                var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    
    
    
                var gmarkers = [];
    
    
                for (var i = 0; i < markers.length; i++) {
                    var data = markers[i]
                    var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                    var marker = new google.maps.Marker({
                        ,
                        map: map,
                        title: data.City,
                        url: data.Url,
                        optimized: false
                    });
    
    
                    marker.content = '<div class="info_content">' +
    
    
                 '<img width="100" src="' + data.ImagePath + '"/>'
             + "<br>" +
    
        "<h3>" + '</h3>' + "<h3>" + "<b>" + data.StageName + "</b>" + '</h3>' +
    "<a href='" + data.Url + "' >View Listing</a>" + '</div>';
    
    
    
    
    
    
    
    
    
                    gmarkers.push(marker);
    
    
                    (function (marker, data) {
                        google.maps.event.addListener(marker, "click", function (e) {
                            window.location = marker.url;
                        });
                    })(marker, data);
                    latlngbounds.extend(marker.position);
    
    
    
    
    
    
                    (function (marker, data) {
    
                        // Attaching a click event to the current marker
                        google.maps.event.addListener(marker, "mouseover", function (e) {
                            infoWindow.setContent(marker.content);
                            infoWindow.open(map, this);
                        });
                    })(marker, data);
    
    
    
    
                }
    
    
    
    
    
    
                var bounds = new google.maps.LatLngBounds();
                map.setCenter(latlngbounds.getCenter());
                map.fitBounds(latlngbounds);
    
    
    
                var mcoptions = { zoomOnClick: true, showText: true, averageCenter: true, maxZoom: 10 }
    
                var markerCluster = new MarkerClusterer(map, gmarkers, mcoptions);
    
    
    
    
    
            }
    
    
            google.maps.event.addDomListener(window, 'load', initialize);
    
    
        </script>
    
    

    Wednesday, March 16, 2016 8:20 PM

Answers