[英]custom icon from url, not from assets - nativescript google maps ios
I try a lot but not success to find a way to show icon of marker from url.我尝试了很多但没有成功找到一种方法来显示来自 url 的标记图标。
addMarker(mark, index): void {
const marker = new Marker();
marker.position = Position.positionFromLatLng(mark.latitude, mark.longitude);
marker.icon = 'iconsdb.com/icons/preview/red/map-marker-2-xxl.png'; // default pin
this.mapView.addMarker(marker);
}
Using this for icons image from assets was working fine.将其用于资产中的图标图像效果很好。 now I have icons stored on cloud and I need to use them as per record.
现在我将图标存储在云中,我需要根据记录使用它们。
Since loading image from assets works with an ImageSource, I believe you should be able to do a similar thing for images from URL.由于从资产加载图像与 ImageSource 一起工作,我相信您应该能够对来自 URL 的图像执行类似的操作。 Also see documentation
另见文档
The ImageSource has a 'fromUrl' you can call. ImageSource 有一个可以调用的“fromUrl”。 So this should work for you (borrowing part of the code from your linked question)
所以这应该对你有用(从你的链接问题中借用部分代码)
let imgSrc = new ImageSource();
imgSrc.fromUrl("iconsdb.com/icons/preview/red/map-marker-2-xxl.png");
let image = new Image();
image.imageSource = imgSrc;
marker.icon = image;
You should probably cache the image so it won't be downloaded x times.您可能应该缓存图像,这样它就不会被下载 x 次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.