Map – default spot / map when no geolocation allowed or found

WCMp Core

Map – default spot / map when no geolocation allowed or found Resolved

Viewing 7 reply threads
  • Author
    Posts
    • #92175
      itunes_schreiber
      Participant

      Hi,

      I’m using the Google Vendor Map within all vendors will be displayed. This is working like a charm – great work! 🙂

      Now I would like to have, that when no geolocation will be allowed / found, that a default fix spot / map will be displayed.
      Because the map is the first thing what you can see on my website and a lot of people firstly do not allow any geolocation until they know something about the site and trust it. So if they don’t allow the geolocation, there is just a big grey box – which looks not sooo great.

      Thank you very much.

    • #92291

      Hi @itunes_schreiber,
      You can use wcmp_vendor_list_get_wcmp_vendors_args this filter to modify vendor list.

    • #92296
      itunes_schreiber
      Participant

      Hi Raju,
      thanks for the reply.

      Not sure if you had understood my query correctly (or may I just don’t get it).
      Wasn’t able to comprehend how the wcmp_vendor_list_get_wcmp_vendors_args filter is helping me out here.
      As I can understand, this is just to filter the vendor lists?

      I don’t understand, how I could use this regarding a default location on the map?

      Can you please assist with some further details / provide an example?
      Thanks.

    • #92363

      Hi @itunes_schreiber,
      Sorry for the previous answer.Now you want to set default location data on the map if customer do not allow location also.
      So for that, we don’t have any filter. All these works are done in the js file which is given below.

      https://github.com/wcmarketplace/dc-woocommerce-multi-vendor/blob/master/assets/frontend/js/vendor-list.js
      Copy

      So now if you want to modify this then you have to modify two lines in that file.
      just replace line no 47 and 51 with below code( You may set your own lat and lang according to your choice )

      var mapProp= {
      center:new google.maps.LatLng( 22.5726,88.3639 ),
      zoom:5,
      };
      var map = new google.maps.Map(document.getElementById("wcmp-vendor-list-map"),mapProp);
      Copy
    • #92369
      itunes_schreiber
      Participant

      Hi Raju,
      thanks for the help. This is working so far. I have some following questions here.

      1. How or is it even possible when using the default spot, so when no gelocation is allowed, that the vendors shops anyway will be shown on the map?
      Because when I use your code snippet, the marker are gone and for a visitor this may will be recognized as an issue / absolutely none shop is available.

      2. When using the code, it’s also not possible to type in a address to search any shops.
      Is it possible that this will work anyway, when the default map will be displayed?

      Thank you very much for your assist.

    • #92753
      itunes_schreiber
      Participant

      Hi Raju,

      any updates you can provide regarding this topic?

      Regards,
      Lukas

    • #92768

      Hi @itunes_schreiber,
      Please remove the previous code and then add this code on previously instructed lines: “So now if you want to modify this then you have to modify two lines in that file.
      just replace line no 47 and 51 with below code( You may set your own lat and lang according to your choice )”

      var mapProp= {
                          center:new google.maps.LatLng( 22.5726,88.3639 ),
                          zoom:5,
                      };
                      var map = new google.maps.Map(document.getElementById("wcmp-vendor-list-map"),mapProp);
                      var input = document.getElementById("locationText");
                      var autocomplete = new google.maps.places.Autocomplete(input);
                      autocomplete.addListener("place_changed", function() {
                          var place = autocomplete.getPlace();
                          if (!place.geometry) {
                              window.alert("Autocomplete returned place contains no geometry");
                              return;
                          }
                      // If the place has a geometry, then present it on a map.
                      if (place.geometry.viewport) {
                          map.fitBounds(place.geometry.viewport);
                      } else {
                          map.setCenter(place.geometry.location);
                          map.setZoom(17);
                      }
                      // set center position
                      $('#wcmp_vlist_center_lat').val(place.geometry.location.lat());
                      $('#wcmp_vlist_center_lng').val(place.geometry.location.lng());
                      //place.geometry.location.lat(),place.geometry.location.lng()
                      });
      
                      function createMarker(storeInfo) { 
                          bounds.extend(new google.maps.LatLng(storeInfo.location.lat, storeInfo.location.lng));
                          var marker = new google.maps.Marker({
                              map: map,
                              icon: wcmp_vendor_list_script_data.map_data.marker_icon,
                              position: new google.maps.LatLng(storeInfo.location.lat, storeInfo.location.lng),
                              title: storeInfo.store_name
                          });
                          google.maps.event.addListener(marker, "click", function() {
                              infoWindow.setContent(storeInfo.info_html);
                              infoWindow.open(map, marker);
                          });
                          markers.push(marker);
                      }
      
                      wcmp_vendor_list_script_data.stores.forEach(function(store){
                          createMarker(store);
                      }); 
      Copy
    • #92778
      itunes_schreiber
      Participant

      Hi Raju,

      thanks for the reply and the code.
      This is working perfectly.

      Thank you very very much.
      You can mark the ticket as resolved.

      Regards and have nice day. 🙂

Viewing 7 reply threads

The topic ‘Map – default spot / map when no geolocation allowed or found’ is closed to new replies.

COVID-19 Outbreak: WCMp team is supporting business affected by coronavirus

Read the Message Buy at Slashed Price