Show All Dealers
Permalink Browser Info Environment
I know this has already been asked but the responses from the other post didn't seem to help me.
I need to be able to show all 396 dealer locations when the page first loads. I've tried manually inserting USA into the text field but I still have to select a distance. Even if I select 250 miles, it still doesn't show me all of the locations.
I am running version 1.2 of the dealer locator. I'd prefer to not have to upgrade but will if there's a solution to this in a newer version.
Is there a way to show all locations regardless of distance when the page first loads?
I need to be able to show all 396 dealer locations when the page first loads. I've tried manually inserting USA into the text field but I still have to select a distance. Even if I select 250 miles, it still doesn't show me all of the locations.
I am running version 1.2 of the dealer locator. I'd prefer to not have to upgrade but will if there's a solution to this in a newer version.
Is there a way to show all locations regardless of distance when the page first loads?
Type: | Discussion |
---|---|
Status: | In Progress |
Thanks. How would I show them all by default? Currently, no dealers show by default.
If you need to show developers from coast to coast, I suppose you could use a centrally located US address (Or USA might select the center of the US by default) and then set the distance to show to the distance from that point to one of the coasts (roundabout of course, around 1300 miles or something along those lines.
Okay thanks. How do I make it automatically show dealers based on USA and 1300 miles when the page first loads? Is there some javascript I can add that'll do that or is there something I need to add to the view?
Hello,
You can set the starting lattitude / longitude by creating a template for the block. Copy the view.php for the block into your template folder and starting on line 18 you can adjust the zoom level and center for the map when it loads.
This how-to has some good links about how to create templates:
http://www.concrete5.org/documentation/how-tos/developers/change-th...
You can set the starting lattitude / longitude by creating a template for the block. Copy the view.php for the block into your template folder and starting on line 18 you can adjust the zoom level and center for the map when it loads.
This how-to has some good links about how to create templates:
http://www.concrete5.org/documentation/how-tos/developers/change-th...
Around line 136 you will see this
You will need to edit this to be
Of course you will have to replace "yourzipcode" with a zip code to search on and replace "predetermineddistance" with a distance.
$(document).ready(function (){ load<?php echo $controller->bID?>(); $('.ccm-locator-map-address').val() && searchLocations(); });
You will need to edit this to be
$(document).ready(function (){ load<?php echo $controller->bID?>(); var address = $('#ccm-locator-search-<?php echo $controller->bID?> input[name=address]').val(yourzipcode); var radius = $('#ccm-locator-search-<?php echo $controller->bID?> #radius').val(predetermineddistance); searchLocations();// call the search locations function });
Of course you will have to replace "yourzipcode" with a zip code to search on and replace "predetermineddistance" with a distance.
This works to show all locations, but then all locations show no matter how the map is filtered. The sidebar results are accurate, but all markers show on the map.
Any other ideas? Something that would call the search function without populating the form fields would be optimal. As this solution displays the zip code on load, and if you want to show results across multiple states, it's a bit confusing to the end user.
Thanks for posting this either way!
Any other ideas? Something that would call the search function without populating the form fields would be optimal. As this solution displays the zip code on load, and if you want to show results across multiple states, it's a bit confusing to the end user.
Thanks for posting this either way!
Here's a way you can approach this using the latest version. It requires some custom coding.
1. Make a "dealer_search" directory in your root blocks directory. Copy the view.php, view.js, tools/ and css/ directories from the packages/dealer_locator/blocks/dealer_search/ into this directory.
2. First, we're going to add support for a new parameter in view.js. This is "initial". It is the state of the search results when you come to the block. It can either by "all" or "none" (none is the current default.)
First we add it to our options array.
Next we add some code further down specifying whether the current request is the initial search request:
Next we're going to handle the clearing of markers. I don't think this even exists for our current version. We add this method to the JavaScript:
[/code]
clearMarkers: function() {
for (var i = 0; i < dl.markers.length; i++) {
dl.markers[i].setMap(null);
}
dl.markers = [];
},
[/code]
Next, we make sure we actually are adding a marker to the array when we add it:
(the only different here is the dl.markers.push line)
Next, we modify the performSearch method to pass along our "initial" parameter, whether it is the initial request, and enable the clearing of markers and the unsetting of our isInitial parameter:
3. Now that our JS is modified, we need to modify the view.php to pass in the "initial" parameter. We want to set it to "all" instead of the none it'll be set to by default:
Now, we need to modify our dealer list search AJAX. Open tools/search.php and change these lines:
to this:
And that should be enough to get you moving in the right direction.
1. Make a "dealer_search" directory in your root blocks directory. Copy the view.php, view.js, tools/ and css/ directories from the packages/dealer_locator/blocks/dealer_search/ into this directory.
2. First, we're going to add support for a new parameter in view.js. This is "initial". It is the state of the search results when you come to the block. It can either by "all" or "none" (none is the current default.)
First we add it to our options array.
defaultOptions = { zoom: 7, center: 'USA', mapSettings: {}, listSettings: {}, mapTypeId: 'ROADMAP', type: 'any', initial: 'none', radius: 10, units: 'miles', searchForm: $('<form></form>'), listField: $('<div></div>') };
Next we add some code further down specifying whether the current request is the initial search request:
Next we're going to handle the clearing of markers. I don't think this even exists for our current version. We add this method to the JavaScript:
[/code]
clearMarkers: function() {
for (var i = 0; i < dl.markers.length; i++) {
dl.markers[i].setMap(null);
}
dl.markers = [];
},
[/code]
Next, we make sure we actually are adding a marker to the array when we add it:
addMarker: function (markerOb,infoWindow) { var marker = new google.maps.Marker(markerOb); google.maps.event.addListener(marker, 'click', function() { dl.methods.closeInfoWindows(); infoWindow.open(dl.map, marker); }); dl.methods.addBound(markerOb.position); dl.markers.push(marker); return marker; },
(the only different here is the dl.markers.push line)
Next, we modify the performSearch method to pass along our "initial" parameter, whether it is the initial request, and enable the clearing of markers and the unsetting of our isInitial parameter:
searchUrl = searchUrl + '?lat=' + center.lat() + '&lng=' + center.lng() + '&initial=' + dl.settings.initial + '&isInitial=' + dl.isInitial + '&radius=' + dl.settings.radius + '&type=' + dl.settings.type + '&units=' + dl.settings.units; var i = dl.infoWindow.length; dl.methods.resetBounds(); dl.isInitial = 0; dl.methods.clearMarkers();
3. Now that our JS is modified, we need to modify the view.php to pass in the "initial" parameter. We want to set it to "all" instead of the none it'll be set to by default:
var options = { // miscellaneous items snipped initial: 'all', // etc... };
Now, we need to modify our dealer list search AJAX. Open tools/search.php and change these lines:
$distanceList = new DealerDistanceList($_REQUEST['lat'],$_REQUEST['lng'],$_REQUEST['radius'],$_REQUEST['units']); $distanceList->sortBy('distance','ASC'); if(strlen($_REQUEST['type']) && $_REQUEST['type'] != 'any') { $distanceList->filter('type',$_REQUEST['type']); }
to this:
if ($_REQUEST['initial'] == 'all' && $_REQUEST['isInitial'] == 1) { $distanceList = new DealerList(); } else { $distanceList = new DealerDistanceList($_REQUEST['lat'], $_REQUEST['lng'], $_REQUEST['radius'], $_REQUEST['units']); $distanceList->sortBy('distance','ASC'); if(strlen($_REQUEST['type']) && $_REQUEST['type'] != 'any') { $distanceList->filter('type',$_REQUEST['type']); } }
And that should be enough to get you moving in the right direction.
You should be able to add in another distance zoom level in the text box in the block edit screen, so under 250, you would just press return and add, for instance, 500. Let me know if that gets all your dealers displaying.