Placeholder Google Maps without plugin
-
Hello ??
I have a Google Maps on a website without plugin.
I load the API JS in my header :
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=xxx" defer></script>
And this is my JS :
function initGoogleMaps() { var latitude = $('#google_maps').attr('data-lat'), longitude = $('#google_maps').attr('data-lng'), url = $('#google_maps').attr('data-url'); var options = { disableDefaultUI: true, zoom: 16, center: new google.maps.LatLng(latitude, longitude), mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, position: google.maps.ControlPosition.LEFT_BOTTOM }, scrollwheel: false, streetViewControl: false, mapTypeControl: false, draggable: true } var map = new google.maps.Map(document.getElementById('google_maps'), options); var marker = new google.maps.Marker({ position: new google.maps.LatLng(latitude, longitude), map: map, animation: google.maps.Animation.DROP, icon: new google.maps.MarkerImage(blogInfo.url+'/wp-content/themes/test/images/pin.svg'), url: url }); google.maps.event.addListener(marker, 'click', function() { window.open(this.url, '_blank'); }); } initGoogleMaps();
So I put my JS in the script center in the async textarea.
All is work, the map is loaded only if the user has accepted the cookies. But I don’t have the placeholder if the user has not yet accepted the cookies.Could you help me ?
Thank you !
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Placeholder Google Maps without plugin’ is closed to new replies.