Last active
October 20, 2015 21:43
-
-
Save agustinprosperi/e83f1cf6edd4669d1027 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div id="loadgooglemap"></div> | |
<script src="//maps.google.com/maps/api/js?sensor=true" type="text/javascript"></script> | |
<script type="text/javascript"> | |
jQuery(function($) { | |
//------- Google Maps ---------// | |
<?php | |
$latlng = '-17.8126693,-63.1751292'; | |
$cr_text = 'mi texto va aquí'; | |
?> | |
// Creating a LatLng object containing the coordinate for the center of the map | |
var latlng = new google.maps.LatLng(<?php echo $latlng; ?>); | |
// Creating an object literal containing the properties we want to pass to the map | |
var options = { | |
scrollwheel: false, | |
//draggable: false, | |
zoom: 16, // This number can be set to define the initial zoom level of the map | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, // This value can be set to define the map type ROADMAP/SATELLITE/HYBRID/TERRAIN | |
//***descomentar si queres estilo negro como lo que te mostre | |
/*styles: [{"featureType":"all","elementType":"all","stylers":[{"saturation":-100},{"gamma":0.3},{"lightness": 0}]}, | |
{"featureType": "road", "elementType": "geometry.fill","stylers": [{"color": "#d1d1d1"}]}]*/ | |
}; | |
// Calling the constructor, thereby initializing the map | |
var map = new google.maps.Map(document.getElementById('loadgooglemap'), options); | |
// Define Marker properties | |
var image = new google.maps.MarkerImage('<?php echo get_template_directory_uri(); ?>/images/gm-pin.png', | |
// This marker is 129 pixels wide by 42 pixels tall. | |
new google.maps.Size(43, 43), | |
// The origin for this image is 0,0. | |
new google.maps.Point(0,0), | |
// The anchor for this image is the base of the flagpole at 18,42. | |
new google.maps.Point(21, 21) | |
); | |
// Add Marker | |
var marker1 = new google.maps.Marker({ | |
position: new google.maps.LatLng(<?php echo $latlng; ?>), | |
map: map, | |
icon: image // This path is the custom pin to be shown. Remove this line and the proceeding comma to use default pin | |
}); | |
// Add listener for a click on the pin | |
google.maps.event.addListener(marker1, 'click', function() { | |
infowindow1.open(map, marker1); | |
}); | |
// Add information window | |
var infowindow1 = new google.maps.InfoWindow({ | |
content: createInfo('<?php bloginfo("name"); ?>', '<?php echo nl2br( eregi_replace("[\n|\r|\n\r]", " ", $cr_text) ); ?>') | |
}); | |
// Create information window | |
function createInfo(title, content) { | |
return '<div class="infowindow"><strong>'+ title +'</strong><br/><div>'+content+'</div></div>'; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment