Anonymous Anonymous - 1 month ago 146 0

No description

PHP

generateMap()

public function generateMap() {
		?>
		<div class="img-header-map">
			<div id="map">
			<script> 
				var myLatLng = {lat: 47.359979, lng: 8.649155};
				var map;

				function initMap() {
					var zoom = 10;
					if($(window).innerWidth() > 1023) {
						zoom = 12;
					}
			        map = new google.maps.Map(document.getElementById('map'), {
				        center: myLatLng,
				        scrollwheel: false,
				        mapTypeId: google.maps.MapTypeId.ROADMAP,
				        zoom: zoom,
				        styles: [
				            {
				            	featureType: 'road',
								stylers: [
									{ saturation: -50 }
								]
							},{
				            	featureType: 'poi.park',
				            	elementType: 'geometry.fill',
								stylers: [
									{ visibility: 'off' }
									
								]
							},{
								featureType: "poi.business",
								elementType: "labels",
								stylers: [
									{ visibility: "off" }
								]
							}
						]
			        });

			        var icons = {
			          gutsehen: {
			            icon: '/templates/web/img/marker.png'
			          }
			      	};

			        function addMarker(feature) {
			          var marker = new google.maps.Marker({
			            position: feature.position,
			            icon: icons[feature.type].icon,
			            map: map
			          });
			        }

			        var features = [
			          {
			            position: new google.maps.LatLng(47.358711, 8.549361),
			            type: 'gutsehen'
			          }, {
			            position: new google.maps.LatLng(47.366200, 8.781897),
			            type: 'gutsehen'
			          }
			    	];

				    for (var i = 0, feature; feature = features[i]; i++) {
			          addMarker(feature);
			        }
				}
				function toggleBounce() {
					if (marker.getAnimation() !== null) {
						marker.setAnimation(null);
					} else {
						marker.setAnimation(google.maps.Animation.BOUNCE);
						setTimeout(function() {
							marker.setAnimation(null);
						}, 800);
					}
				}
				</script>
				<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDiDkLFtgHbC0Wi5mCqOMjKWAP-0bFeaVI&callback=initMap"
				async defer></script>
			</div>
		</div>
		<?php
	}
Comments