Skip to content

Instantly share code, notes, and snippets.

@katzueno
Last active December 28, 2015 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katzueno/fd49f260db499ea58a75 to your computer and use it in GitHub Desktop.
Save katzueno/fd49f260db499ea58a75 to your computer and use it in GitHub Desktop.
concrete5.7.3: Google Map Block override sample: add "view this map in a new window" link

concrete5 Google Map Block override sample: add "view this map in a new window" link

This will add "view larger map" link to Google Map block Please save the the following view.php file onto /application/blocks/google_map/view.php

Changes from 5.7.3. default view.php

I've changed the following

  • LINE 9: added margn-top 1em
  • LINE 11: Link to Google Map added. If you're buiding a multilingual site, use the translation interface of concrete5 to make the message string multilingual.

concrete5 の Google Map に「大きな地図で見る」リンクを追加

concrete5.7.3 の Google Map に「大きな地図で見る」リンクを追加します。

/application/blocks/google_map/view.php に下記のファイルをアップロードしてください。 11行目のリンクの文字は適宜変えると良いでしょう

5.7.3 のデフォルトよりカスタマイズしたところ

  • 9行目のタイトルを表示するところで、 margin-top 1em を追加
  • 11行目に、Google Map へのリンクを追加しています。「View this map in a new window」が英語なので日本語に修正してもいいですし、多言語サイト機能を使っているのであれば concrete5 の翻訳インターフェースから翻訳し多言語対応できます。
<?php defined('C5_EXECUTE') or die("Access Denied.");
$c = Page::getCurrentPage();
if ($c->isEditMode()) { ?>
<div class="ccm-edit-mode-disabled-item" style="width: <?php echo $width; ?>; height: <?php echo $height; ?>">
<div style="padding: 80px 0px 0px 0px"><?php echo t('Google Map disabled in edit mode.')?></div>
</div>
<?php } else { ?>
<?php if( strlen($title)>0){ ?><h3 style="margin-top:1em;"><?php echo $title?></h3><?php } ?>
<div id="googleMapCanvas<?php echo $unique_identifier?>" class="googleMapCanvas" style="width: <?php echo $width; ?>; height: <?php echo $height; ?>"></div>
<p><a href="https://www.google.co.jp/maps/place/<?php echo urlencode($location);?>/@<?php echo urlencode($latitude);?>,<?php echo urlencode($longitude);?>,15z" target="_blank"><?php echo t('View this map in a new window');?></a></p>
<?php } ?>
<?php
/*
Note - this goes in here because it's the only way to preserve block caching for this block. We can't
set these values through the controller
*/
?>
<script type="text/javascript">
function googleMapInit<?php echo $unique_identifier?>() {
try{
var latlng = new google.maps.LatLng(<?php echo $latitude?>, <?php echo $longitude?>);
var mapOptions = {
zoom: <?php echo $zoom?>,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false,
scrollwheel: <?php echo !!$scrollwheel ? "true" : "false"?>,
mapTypeControl: false
};
var map = new google.maps.Map(document.getElementById('googleMapCanvas<?php echo $unique_identifier?>'), mapOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map
});
}catch(e){
$("#googleMapCanvas<?php echo $unique_identifier?>").replaceWith("<p>Unable to display map: "+e.message+"</p>")}
}
$(function() {
var t;
var startWhenVisible = function (){
if ($("#googleMapCanvas<?php echo $unique_identifier?>").is(":visible")){
window.clearInterval(t);
googleMapInit<?php echo $unique_identifier?>();
return true;
}
return false;
};
if (!startWhenVisible()){
t = window.setInterval(function(){startWhenVisible();},100);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment