<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC-PtN8VgEMLGrWvmcfBHQF8IBLqyQTAV4&callback=init" async defer></script>
/*google.maps.event.addDomListener(window, 'load', init);
google.maps.event.addDomListener(window, 'load', init);*/
function init() {
var myLatlng = new google.maps.LatLng(<?php echo of_get_option('latitude'); ?>, <?php echo of_get_option('longitude'); ?>);
var myLatlng2 = new google.maps.LatLng(<?php echo of_get_option('latitude2'); ?>, <?php echo of_get_option('longitude2'); ?>);
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: <?php echo of_get_option('zoom'); ?>,
scrollwheel: false,
// The latitude and longitude to center the map (always required)
center: myLatlng, // Santa Barbara
// How you would like to style the map.
// This is where you would paste any style found on Snazzy Maps.
styles:
[
{
"featureType": "landscape.man_made",
"elementType": "geometry",
"stylers": [
{
"color": "#f7f1df"
}
]
}
]
};
var mapOptions2 = {
zoom: <?php echo of_get_option('zoom'); ?>,
scrollwheel: false,
center: myLatlng2, // Santa Barbara
styles:
[
{
"featureType": "landscape.man_made",
"elementType": "geometry",
"stylers": [
{
"color": "#f7f1df"
}
]
}
]
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var map2 = new google.maps.Map(document.getElementById('map2'), mapOptions2);
var contentString = '<div id="content"><?php $desc = of_get_option("description"); echo str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $desc); ?></div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var infowindow2 = new google.maps.InfoWindow({
content: contentString
});
var image = '<?php echo get_stylesheet_directory_uri(); ?>/images/marker.png';
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: image
});
var marker2 = new google.maps.Marker({
position: myLatlng2,
map: map2,
icon: image
});
// To add the marker to the map, call setMap();
marker.setMap(map);
marker2.setMap(map2);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
google.maps.event.addListener(marker2, 'click', function() {
infowindow2.open(map2,marker2);
});
}
<div id="map"></div>
<div id="map2"></div>