Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second event it's not loading in Mobile #245

Open
blasruizabinbev opened this issue Nov 7, 2019 · 0 comments
Open

Second event it's not loading in Mobile #245

blasruizabinbev opened this issue Nov 7, 2019 · 0 comments

Comments

@blasruizabinbev
Copy link

blasruizabinbev commented Nov 7, 2019

I have a project where i use Selectric.

My first event works, but for the second one, there is nothing that makes it work. It's like the disableOnMobile:false configuration was not being loaded.

Here is how it looks:

var map;
var markers = [];

function initMap() {
    map = new google.maps.Map(document.getElementById('map'), {
        center: {
            lat: -25.72289,
            lng: 27.85378
        },
        zoom: 4
    });
    jQuery.each(stores, function(index, val) {
        var lat = val.Latitude.replace(",", ".");
        var lng = val.Longitude.replace(",", ".");
        var myLatlng = new google.maps.LatLng(lat, lng);
        var marker = new google.maps.Marker({
            position: myLatlng,
            title: val.Name,
            map: map,
        });
        var contentString = '<div id="content">' + '<div id="siteNotice">' + '</div>' + '<h2 id="firstHeading" class="firstHeading">' + val.Name + '</h2><p>' + val.Address1+" " +val.Address2+", <br>"+val.Address3+"<strong>"+val.City+","+val.PostalCode+"</strong>"+'</p></div>';
        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });
        marker.addListener('click', function() {
            infowindow.open(map, marker);
        });
        markers.push(marker);
    });
    var markerCluster = new MarkerClusterer(map, markers, {
        imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'
    });
    jQuery('#region').selectric({
        disableOnMobile: false,
        nativeOnMobile: false
    });
    jQuery('#region').on('selectric-select', function(event, element, selectric) {
        jQuery('#stores').find('option').remove().end().append('<option value="999999">Select One</option>').val('whatever');
        jQuery.each(stores, function(index, val) {
            if (val.City == jQuery(element).val()) {
                console.log(val.City + "   " + jQuery(element).val());
                jQuery('#stores').append('<option value="' + index + '">' + val.Name + '</option>');
            }
        });
        jQuery('#stores').selectric('destroy');
        jQuery('#stores').selectric('init');
    });
    
    jQuery('#stores').selectric({
        disableOnMobile: false,
        nativeOnMobile: false
    });
    
    jQuery('#stores').on('selectric-select', function(event, element, selectric) {
        var lat = stores[jQuery(element).val()].Latitude.replace(",", ".");
        var lng = stores[jQuery(element).val()].Longitude.replace(",", ".");
        var myLatlng = new google.maps.LatLng(lat, lng);
        map.panTo(myLatlng);
        map.setZoom(20);
    });
}

I'm creating a personalized map with different markers. Once the person selects the filters, a new map should load showing the location of the filtered Store.

The second event, the one that loads the new map showing the filtered result, is the one that's not working on mobile.

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant