Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" n:syntax="double">
- var radiusValues = [250, 500, 1000, 2000, 5000, 10000, 25000, 50000];
- var radius = {{$radius}};
- var orderBy = 'distance';
- var markers = [];
- $(document).ready(function() {
- var mapOptions = {
- zoom: 7,
- center: new google.maps.LatLng(49.8865147, 15.7235439),
- mapTypeId: google.maps.MapTypeId.ROADMAP,
- scrollwheel: false,
- zoomControl: false,
- scaleControl: false,
- streetViewControl: false
- };
- GMapV3 = new google.maps.Map(document.getElementById('mapav3'), mapOptions);
- google.maps.event.addListener(GMapV3, 'dragend', function() {
- updateSnippet();
- });
- getPlaceCoords();
- $('body').append('<img id="map-filter" src="/images/map_filter.png">');
- $('#map-filter').css({
- position: 'absolute',
- 'pointer-events': 'none', left: $('#mapav3').offset().left,
- top: $('#mapav3').offset().top
- });
- $('body').append('<a href="javascript:void(0)" onclick="zoom(-1)" id="map-filter-zoom-out"><div style="width:55px; height:51px"><!-- --></div></a>');
- $('#map-filter-zoom-out').css({
- position: 'absolute',
- left: $('#mapav3').offset().left + 253,
- top: $('#mapav3').offset().top + 143
- });
- $('body').append('<a href="javascript:void(0)" onclick="zoom(+1)" id="map-filter-zoom-in"><div style="width:55px; height:51px"><!-- --></div></a>');
- $('#map-filter-zoom-in').css({
- position: 'absolute',
- left: $('#mapav3').offset().left + 634,
- top: $('#mapav3').offset().top + 143
- });
- });
- function getPlaceCoords() {
- var geocoder = new google.maps.Geocoder();
- geocoder.geocode({'address': $('#search-where').val()}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- placeCoords = results[0].geometry.location;
- focusPlace(placeCoords);
- updateSnippet();
- } else {
- alert('Nepodařilo se najít požadované místo, zkuste prosím Váš dotaz zadat jinak.');
- }
- });
- }
- function focusPlace(place) {
- GMapV3.setCenter(place);
- GMapV3.setZoom(21);
- radiusBounds = new google.maps.Circle({radius: parseInt(radius), center: place}).getBounds();
- GMapV3.fitBounds(radiusBounds);
- }
- function zoom(val) {
- var actual = radiusValues.indexOf(radius);
- var tmp = val > 0 ? actual - 1 : actual + 1;
- if (radiusValues[tmp] > 1) {
- radius = radiusValues[tmp];
- updateSnippet();
- }
- }
- function orderResultsBy(value) {
- orderBy = value;
- updateSnippet();
- }
- function updateSnippet() {
- removeAllMarkers();
- $('#mapav3').block({
- message: '<img src="/images/spinner.gif">',
- css: {backgroundColor: 'transparent', border: 'none'}
- });
- $.nette.ajax({
- type: "GET",
- url: {{link searchSnippet!}},
- data: {
- text: {{$what}},
- lat: GMapV3.getCenter().lat(),
- lng: GMapV3.getCenter().lng(),
- radius: radius,
- categories: {{$categories}},
- orderBy: orderBy
- },
- complete: function() {
- $('.jNiceWrapper').on('click', function() {
- $('.jNiceRadio').removeClass('jNiceChecked');
- $(this).children(":first").addClass('jNiceChecked');
- radius = $(this).attr('rel');
- updateSnippet();
- });
- $('#mapav3').unblock();
- focusPlace(GMapV3.getCenter());
- window.history.pushState(null, document.title, {{link search $what}} + "&where=" + GMapV3.getCenter().lat() + "," + GMapV3.getCenter().lng() + "&radius=" + radius);
- }
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement