Last active
August 29, 2015 14:27
-
-
Save kostiantyn-petlia/e1e8bf35ef9f3e4add6e to your computer and use it in GitHub Desktop.
Render script for ACF GooglMap Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//====================================================================================================================== | |
// Google Maps Scripts <div id="acf-map" data-lat="12.345678" data-lng="12.345678"></div> | |
//====================================================================================================================== | |
function render_map($map_div) { | |
// var | |
var lat = $map_div.attr('data-lat'); | |
var lng = $map_div.attr('data-lng'); | |
// coordinates to latLng | |
var latlng = new google.maps.LatLng(lat, lng); | |
// map Options | |
var myOptions = { | |
zoom: 15, | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
//draw a map | |
var map = new google.maps.Map(document.getElementById("acf-map"), myOptions); | |
var marker = new google.maps.Marker({ | |
position: map.getCenter(), | |
map: map | |
}); | |
} | |
// | |
$(document).ready(function() { | |
// Render GoogleMaps | |
$('#acf-map').each(function(){ | |
render_map( $(this) ); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment