Created
October 16, 2014 01:30
-
-
Save dtbaker/417f6155cfe01170e172 to your computer and use it in GitHub Desktop.
google map template file for use with https://gist.github.com/dtbaker/ca76d120df98f6dff50a
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
| <!-- put this file in your theme folder --> | |
| <div id="googlemap<?php echo $map_id; ?>" class="googlemap" style="height:<?php echo $height; ?>px;"></div> | |
| <div class="clear"></div> | |
| <?php if ( $enlarge_button ) { ?> | |
| <div class="map_buttons"> | |
| <a href="http://maps.google.com/maps?q=<?php echo htmlspecialchars( urlencode( $address ) ); ?>" | |
| target="_blank"><?php _e( 'Enlarge Map', 'boutique' ); ?></a> | |
| </div> | |
| <?php } ?> | |
| <?php if ( $map_id == 1 ) { ?> | |
| <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script> | |
| <?php } ?> | |
| <script type="text/javascript"> | |
| (function ($) { | |
| var geocoder; | |
| var map; | |
| var query = "<?php echo addcslashes($address,'"');?>"; | |
| function initialize() { | |
| geocoder = new google.maps.Geocoder(); | |
| var myOptions = { | |
| zoom: <?php echo $zoom;?>, | |
| scrollwheel: false, | |
| /*styles: [ | |
| {"featureType": "water", "stylers": [{"visibility": "on"}, {"color": "#acbcc9"}]}, | |
| {"featureType": "landscape", "stylers": [{"color": "#f2e5d4"}]}, | |
| { | |
| "featureType": "road.highway", | |
| "elementType": "geometry", | |
| "stylers": [{"color": "#c5c6c6"}] | |
| }, | |
| { | |
| "featureType": "road.arterial", | |
| "elementType": "geometry", | |
| "stylers": [{"color": "#e4d7c6"}] | |
| }, | |
| { | |
| "featureType": "road.local", | |
| "elementType": "geometry", | |
| "stylers": [{"color": "#fbfaf7"}] | |
| }, | |
| { | |
| "featureType": "poi.park", | |
| "elementType": "geometry", | |
| "stylers": [{"color": "#c5dac6"}] | |
| }, | |
| {"featureType": "administrative", "stylers": [{"visibility": "on"}, {"lightness": 33}]}, | |
| { | |
| "featureType": "poi.park", | |
| "elementType": "labels", | |
| "stylers": [{"visibility": "on"}, {"lightness": 20}] | |
| }, | |
| {"featureType": "road", "stylers": [{"lightness": 20}]} | |
| ],*/ | |
| controls: { | |
| map_type: { | |
| type: ['roadmap', 'satellite', 'hybrid'], | |
| position: 'top_right', | |
| style: 'dropdown_menu' | |
| }, | |
| overview: {opened: false}, | |
| pan: false, | |
| rotate: false, | |
| scale: false, | |
| street_view: {position: 'top_right'}, | |
| zoom: { | |
| position: 'top_left', | |
| style: 'large' | |
| } | |
| }, | |
| mapTypeId: google.maps.MapTypeId.ROADMAP | |
| }; | |
| map = new google.maps.Map(document.getElementById("googlemap<?php echo $map_id;?>"), myOptions); | |
| codeAddress(); | |
| } | |
| function codeAddress() { | |
| var address = query; | |
| geocoder.geocode({'address': address}, function (results, status) { | |
| if (status == google.maps.GeocoderStatus.OK) { | |
| var marker = new google.maps.Marker({ | |
| map: map, | |
| position: results[0].geometry.location | |
| }); | |
| <?php if(strlen($innercontent)){ ?> | |
| var infowindow = new google.maps.InfoWindow({ | |
| content: unescape("<?php echo str_replace('+',' ',(preg_replace('/\s+/',' ',addcslashes($innercontent,'"'))));?>") | |
| }); | |
| google.maps.event.addListener(marker, 'click', function () { | |
| infowindow.open(map, marker); | |
| }); | |
| infowindow.open(map, marker); | |
| <?php } ?> | |
| map.setCenter(marker.getPosition()); | |
| setTimeout(function () { | |
| map.panBy(0, -50); | |
| }, 10); | |
| } else { | |
| alert("Geocode was not successful for the following reason: " + status); | |
| } | |
| }); | |
| } | |
| $(function () { | |
| initialize(); | |
| }); | |
| }(jQuery)); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment