2017年1月16日月曜日

Google Mapユーザーコントロールが使えない!?

業務アプリケーションの中で位置情報を判りやすく表示するツールとしてGoogle Mapを使用している方も多いと思います。GeneXusでもユーザーコントロールとして提供されているため、比較的簡単に実装できます。

ところが、そのGoogle Mapが突然表示されなくなる。という事態が昨年起こりました。

アプリケーション内でGoogle Mapを表示するとエラーとなってしまう。
デバッガで見てみると「NoApiKeys」というエラーメッセージが表示されている

これはGoogle側の利用規約が変更されたためで、Google Mapを利用するにはAPIキーの指定が必須となりました。

https://maps-apis.googleblog.com/2016/06/building-for-scale-updates-to-google.html
We no longer support keyless access (any request that doesn't include an API key). Future product updates are only available for requests made with an API key. API keys allow us to contact developers when required and help us identify misbehaving implementations.


GeneXusとしてはEvolution3 Upgrade9からAPIキーのサポートがされました。
https://www.genexus.com/developers/websac?en,,,39706;;

SAC #39706: ApiKey support in Web control Map

Abstract
Version 8.2 of the control made it possible to enter an ApiKey at design time. This is required as from June 22, 2016, due to a change in the licensing policy of the Google Map API. If a key is not provided, the error ApiKeyNotFound occurs at runtime and the map is not displayed.
しかし、それ以前のGeneXusを使用している場合はどうしたらよいでしょうか? 探してみたところ、GeneXusマーケットプレースに新しいバージョンのMAPユーサーコントロールがアップされていました。
https://marketplace.genexus.com/product.aspx?mapcontrol,en
こちらからユーザーコントロールをダウンロードし、GeneXusにインストールして下さい。

ユーザーコントールのプロパティに「Google Api Key」が追加されている

Google API KEYの取得はこちらから。
https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,places_backend&reusekey=true

API KEYを取得するにはGoogleアカウントが必要です。また、API KEYを取得する際にリファラーやIPでキーの制限を指定する事ができます。






0 件のコメント:

コメントを投稿