メインコンテンツ

OpenStreetMap ベースマップでのデータの表示

この例では、OpenStreetMap® ベースマップで走行ルートおよび車両位置を表示する方法について説明します。

geoplayer オブジェクトで使用できるベースマップのリストに OpenStreetMap ベースマップを追加します。ベースマップを追加した後には、将来のセッションでそのベースマップを再度追加する必要はありません。

name = 'openstreetmap';
url = 'https://a.tile.openstreetmap.org/${z}/${x}/${y}.png';
copyright = char(uint8(169));
attribution = copyright + "OpenStreetMap contributors";
addCustomBasemap(name,url,'Attribution',attribution)

緯度と経度の座標のシーケンスを読み込みます。

data = load('geoRoute.mat');

Geographic Player を作成します。Geographic Player を走行ルートの開始位置の中央に配置し、ズーム レベルを 12 に設定します。

zoomLevel = 12;
player = geoplayer(data.latitude(1),data.longitude(1),zoomLevel);

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object is empty.

完全なルートを表示します。

plotRoute(player,data.latitude,data.longitude);

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 2 objects of type line, scatter.

既定では、Geographic Player は、Esri® が提供している World Street Map ベースマップ ('streets') を使用します。代わりに追加した OpenStreetMap ベースマップを使用するように Geographic Player を更新します。

player.Basemap = 'openstreetmap';

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 2 objects of type line, scatter.

ルートを再度表示します。

plotRoute(player,data.latitude,data.longitude);

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 4 objects of type line, scatter.

シーケンス内の車両の位置を表示します。

for i = 1:length(data.latitude)
   plotPosition(player,data.latitude(i),data.longitude(i))
end

Figure Geographic Player contains an axes object with type geoaxes. The geoaxes object contains 6 objects of type line, scatter, text.

参考

| | | |