Skip to content

Instantly share code, notes, and snippets.

@steelydylan
Last active October 18, 2018 02:36
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 steelydylan/d288514741dbd6303b17a42f2d8f22f5 to your computer and use it in GitHub Desktop.
Save steelydylan/d288514741dbd6303b17a42f2d8f22f5 to your computer and use it in GitHub Desktop.
a-blog cms のカスタムフィールドでyahooMapを利用する
<table class="formColumnMap js-yahoo-map">
<tr>
<td class="formColumnMapTd">
<!-- BEGIN_IF [%{PROTOCOL}/eq/https] -->
<img class="column-map js-map_editable-container" src="//map.yahooapis.jp/map/V1/static?appid=%{YAHOO_API_KEY}&lat={mapLat}&lon={mapLng}&z={mapZoom}&width=400&height=400&pointer=on"
width="400" height="400">
<!-- ELSE -->
<img class="column-map js-map_editable-container" src="//map.olp.yahooapis.jp/OpenLocalPlatform/V1/static?appid=%{YAHOO_API_KEY}&lat={mapLat}&lon={mapLng}&z={mapZoom}&width=400&height=400&pointer=on"
width="400" height="400">
<!-- END_IF -->
</td>
<td class="entryFormFileControl">
<table class="entryFormMapTable">
<tr>
<th><label for="unit-yolp-lat-{id}">
緯度
</label></th>
<td>
<!-- BEGIN_IF [{mapLat}/nem] -->
<input type="text" name="mapLat" value="{mapLat}" size="9" class="acms-admin-form-width-mini js-map_editable-lat">
<!-- ELSE -->
<input type="text" name="mapLat" value="35.185574" size="9" class="acms-admin-form-width-mini js-map_editable-lat">
<!-- END_IF -->
<input type="hidden" name="field[]" value="mapLat" />
</td>
</tr>
<tr>
<th><label for="unit-yolp-lng-{id}">
経度
</label></th>
<td>
<!-- BEGIN_IF [{mapLng}/nem] -->
<input type="text" name="mapLng" value="{mapLng}" size="10" class="acms-admin-form-width-mini js-map_editable-lng">
<!-- ELSE -->
<input type="text" name="mapLng" value="136.899066" size="10" class="acms-admin-form-width-mini js-map_editable-lng">
<!-- END_IF -->
<input type="hidden" name="field[]" value="mapLng" />
</td>
</tr>
<tr>
<th><label for="unit-yolp-zoom-{id}">
ズーム
</label></th>
<td>
<!-- BEGIN_IF [{mapZoom}/nem] -->
<input type="text" name="mapZoom" value="{mapZoom}" size="2" class="acms-admin-form-width-mini js-map_editable-zoom">
<!-- ELSE -->
<input type="text" name="mapZoom" value="10" size="2" class="acms-admin-form-width-mini js-map_editable-zoom">
<!-- END_IF -->
<input type="hidden" name="field[]" value="mapZoom" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<script>
ACMS.Ready(function () {
ACMS.Library.yahooLoadProxy({
'callback': function () {
$('.js-yahoo-map').each(function () {
ACMS.Dispatch.Edit.yolp($(this).get(0));
});
}
});
});
</script>
@steelydylan
Copy link
Author

2.5系の場合のscript

<script>
  ACMS.Ready(function () {
    ACMS.Config.yahoo_api_url = (function(protocol) {
    if (protocol !== 'https:') {
      return 'http://js.api.olp.yahooapis.jp/OpenLocalPlatform/V1/jsapi?appid=' + ACMS.Config.yahooApiKey;
    } else {
      return 'https://map.yahooapis.jp/js/V1/jsapi?appid=' + ACMS.Config.yahooApiKey;
    }
  })(location.protocol);
    ACMS.Library.yahooLoadProxy({
      'callback': function () {
        $('.js-yahoo-map').each(function () {
          console.log(Y);
          ACMS.Dispatch.Edit.yolp($(this).get(0));
        });
      }
    });
  });
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment