Matlab mapping toolbox and the wmmarker function: how to change “description” from a web page to a file on the computer?
조회 수: 7 (최근 30일)
이전 댓글 표시
I use the following matlab code to mark a point on a web map:
close all
webmap('World Imagery');
stationName = 'ST01';
description = '<a href="https://www.mathworks.com" target="_blank" rel="nofollow noopener noreferrer">https://www.mathworks.com</a>';
lat = 69.601142;
lon = 30.025769;
color = [0, 1, 0];
wmmarker(lat,lon,...
'FeatureName',stationName,...
'Description',description,...
'Color',color,...
'AutoFit',true);
The mark is clickable, with a lable containing station name and description of the point. In this minimum working example the description is an url.
How can I format the description variable to point to an image file on my pc?
댓글 수: 0
채택된 답변
Hank
2019년 11월 13일
편집: Hank
2019년 11월 13일
According to the documentation page on wmmarker, "Description elements can be either plain text or HTML markup." HTML links to local files look like this:
<a href="file:///C:\path\to\file">Link Text</a>
So set your description as the HTML code and pass it to wmmarker just like you did:
webmap('World Imagery');
stationName = 'ST01';
description = '<a href="file:///C:\path\to\file">CLICKY</a>';
lat = 69.601142;
lon = 30.025769;
color = [0, 1, 0];
wmmarker(lat,lon,...
'FeatureName',stationName,...
'Description',description,...
'Color',color,...
'AutoFit',true);
Its possible your system will attempt to open the file in a browser, which might be weird depending on what you're trying to open.
추가 답변 (1개)
Hank
2019년 11월 15일
I found the answer! I stumbled across this
I was wrong about the file path. The article says html links accept only http:// or matlab: protocols, the latter runs the matlab code written. So do this!
if you're on windows:
description = '<a href="matlab: winopen(''rel\path\to\file'')">CLICKY</a>'
and if you're on mac/linux
description = '<a href="matlab: unix(''xdg-open rel\path\to\file'')">CLICKY</a>'
Note, the doubled single quotes are used to escape the single quotes... read about it.
The linux bash command to open a file with the default application is xdg-open.
I hope that works! I'm not able to test it with the mapping toolbox, because I don't have it, but it worked printing links to the command line like
disp('<a href="matlab: winopen(''doc.pdf'')">CLICKY</a>')
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!