使用react-native-map中的overlayMapTypes功能
<p><ol>
<li>圖片重複</li>
<li>無法正常運作</li>
<li>url磁磚是伺服器端映像</li>
<li>同一影像顯示超過100次
這段程式碼是web的,如何在react-native中實現,我正在使用react-native-map</li>
</ol>
<p><UrlTile
maximumZ={
18
}
minimumZ={
20
}
tileSize={256}
urlTemplate={imageUrl}
opacity={1.0}
zIndex={-1}
tileCacheMaxAge={20}
doubleTileSize={true}
flipY={false}
/></p>
<pre class="brush:php;toolbar:false;">/*** @license
* 版權所有 2019 Google LLC。
* SPDX許可證識別碼:Apache-2.0*/
function initMap() {
const map = new google.maps.Map(document.getElementById("map"), {
zoom: 18,
center: { lat: 37.783, lng: -122.403 },
});
const bounds = {
17: [
[20969, 20970],
[50657, 50658],
],
18: [
[41939, 41940],
[101315, 101317],
],
19: [
[83878, 83881],
[202631, 202634],
],
20: [
[167757, 167763],
[405263, 405269],
],
};
const imageMapType = new google.maps.ImageMapType({
getTileUrl: function (coord, zoom) {
console.log("coord",coord)
return [
"https://www.gstatic.com/io2010maps/tiles/5/L2_",
zoom,
"_",
coord.x,
"_",
coord.y,
".png",
].join("");
},
tileSize: new google.maps.Size(256, 256),
});
//cosonle.log("imageMapType",imageMapType)
map.overlayMapTypes.push(imageMapType);
}
window.initMap = initMap;</pre>
<p>請提供一個在react-native中使用react-native-map的urlTiles的答案</p>