L
L
Leonid2018-06-19 16:17:20
JavaScript
Leonid, 2018-06-19 16:17:20

Zooming and displaying points on a map in the Google Map API - how?

With the help of the Map List Pro WordPress plugin , a map of dealers is implemented on the site:

spoiler
Wo_Tl3WpQhy1G9iTjsWz_A.png

there is a search for the city - when we drive in, for example, Moscow, then markers of specified locations are displayed within a radius of 60 km from Moscow - however, if you zoom in on the map, then the remaining markers in other cities are not displayed:
spoiler
aH-fpKgHRWiJy5-mxGMrzQ.png

where to look (tweak) so that when searching for any city on the map, all markers would always be displayed:
spoiler
I608CkIZTj60l3a4ckjcQA.png

now this can only be done if you set the marker search radius to 10 thousand km - but then the map is not scaled to the selected city:
spoiler
tHHYwqaARZekaFjC1uqCug.png

a piece of JavaScript code that I think is responsible for this:
spoiler
self.locationSearch = function (data, element) {

            // TODO:Add a binding for this
            // Get the text from the search box
            var locationTerms = ($(element.currentTarget).siblings('.prettySearchValue')).val();

            // Create a geocoder to send to Google
            var geocoder = new google.maps.Geocoder();

            // Add default country if set
            if (mapObject.options.country !== '') {
                locationTerms = locationTerms + ', ' + mapObject.options.country;
            }

            // Make sure geocode exists and send it on
            if (geocoder) {
                // TODO:Add a loader in here while it searches
                geocoder.geocode({'address': locationTerms}, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        // We got an address back so set this
                        self.geocodedLocation({lat:results[0].geometry.location.lat(), lng:results[0].geometry.location.lng()});

                        // Set the query string for checking
                        self.locationquery(locationTerms);
                        // Set sort to distance
                        self.sortDirection('dec');
                        self.selectedSortType('distance');
                        self.sortList('distance');
                    }                    else {
                        // Geocode fail
                        self.geocodeFail(true);
                        console.log("Geocoding failed: " + status);
                    }
                });
            }
        };


Where to dig? Tell me who worked with the Google Map API
ps: tech. support for Map List Pro apparently disappeared, wrote many times - they do not answer ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question