์๋ ํ์ธ์,
๋ฐ์ ๋ค์ดํฐ๋ธ๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ด๊ฒ์ ๋ด map.html ํ์ผ์
๋๋ค.
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<div id="map" style="height: 100%;">
</div>
<script>
var osmUrl = 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {
maxZoom: 18,
attribution: osmAttrib
});
var map = L.map('map').setView([19.04469, 72.9258], 12);
map.addLayer(osm);
</script>
</body>
</html>
webview์ map.html์ ๋ก๋ํ๊ณ ์์ต๋๋ค.
import React, { Component } from 'react';
import {
WebView
} from 'react-native';
export default class MapScreen extends Component {
render() {
return (
<WebView style={{flex:1}} javaScriptEnabled={true} source={require('./map.html')}/>
);
}
}
๊ทธ๋ฌ๋ ํ์ผ์ ios ์๋ฎฌ๋ ์ดํฐ์์ ๋ก๋๋์ง ์์ง๋ง ์๋๋ก์ด๋ ์๋ฎฌ๋ ์ดํฐ์์๋ ๊ด์ฐฎ์ต๋๋ค.
์ด๊ฒ์ ios ์๋ฎฌ๋ ์ดํฐ์์ ๋ณธ ๊ฒ์
๋๋ค.
์๋ ํ์ธ์, ์ด ๋ฌธ์ ๋ React, WebView ๋ฐ iOS ์๋ฎฌ๋ ์ดํฐ์ ๊ด๋ จ์ด ์์ต๋๋ค. Leaflet ํ์ ์ด๋ฌํ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์ง์ํ์ง ์์ผ๋ฏ๋ก ์ด ๋๊ตฌ์ ๋ํด ๋์์ ๋๋ฆด ์ ์์ต๋๋ค.
๋งค์ฐ ๊ฐ๋จํ ์๋ฅผ ๋ณด๋ฉด ๋ฌธ์ ๊ฐ Leaflet ์์ฒด์ ์๋ ๊ฒ์ด ์๋๋ผ ๋ค๋ฅธ ๊ตฌ์ฑ ์์ ์ค ํ๋์ ์ํธ ์์ฉํ๋ ๋ฐฉ์์ ์๋ค๋ ๊ฒ์ด ๋งค์ฐ ๋ถ๋ช ํฉ๋๋ค.
์ฐ๋ฆฌ๋ ๋ค๋ฅธ ๋๊ตฌ์ ๋ ์ ์๋ํ๋๋ก Leaflet์ ๋ณ๊ฒฝํ ์ ์์ง๋ง ๋ถํํ๋ ๋ค๋ฅธ ํ๋ ์์ํฌ๋ ๋๊ตฌ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ๋ฆฌ์์ค๊ฐ ์์ต๋๋ค.
Leaflet, JavaScript ๋ฐ HTML/CSS๋ง ์ฌ์ฉํ์ฌ ์คํจํ ์๋ฅผ ์ ๊ณตํ ์ ์๋ค๋ฉด ์ฐ๋ฆฌ๋ ๋ฌผ๋ก ์ด์ ๋ํด ๋งค์ฐ ๊ฐ๋ฐฉ์ ์ ๋๋ค.
๋ต์ฅ์ ๋ณด๋ด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๋๋ http ์์ฒญ ๋๋ฌธ์ ์์๊ณ ATS ( App Transport Security )๋ฅผ ๋นํ์ฑํํ๋ฉด ์ ๋๋ก ์๋ํ๊ณ ํ์ผ์ด๋ก๋๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์์๋ค์ํผ ATS๋ฅผ ๋นํ์ฑํํ๋ ๊ฒ์ ํด๊ฒฐ์ฑ ์ด ์๋๋๋ค.
Streaming Leaflet Tiles over HTTPS / SSL #3186 ๋ฌธ์ ์ @F1LT3R ๋ต๋ณ์ ๋ฐ๋ฅด๋ฉด ํ์ผ ์ ๋ก๋ํ๊ณ ํ์ผ URL์์ osm์ openstreetmap์ผ๋ก ๋ณ๊ฒฝํ๋ ๋ฐ https๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค( http://{s}.tile.osm.org/{z}/{x}/{y}.png
-> https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
).
@arminghm , ๊ฐ์ฌํฉ๋๋ค. ์ ์๊ฒ ํจ๊ณผ์ ์ ๋๋ค :)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋ต์ฅ์ ๋ณด๋ด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๋๋ http ์์ฒญ ๋๋ฌธ์ ์์๊ณ ATS ( App Transport Security )๋ฅผ ๋นํ์ฑํํ๋ฉด ์ ๋๋ก ์๋ํ๊ณ ํ์ผ์ด๋ก๋๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์์๋ค์ํผ ATS๋ฅผ ๋นํ์ฑํํ๋ ๊ฒ์ ํด๊ฒฐ์ฑ ์ด ์๋๋๋ค.
Streaming Leaflet Tiles over HTTPS / SSL #3186 ๋ฌธ์ ์ @F1LT3R ๋ต๋ณ์ ๋ฐ๋ฅด๋ฉด ํ์ผ ์ ๋ก๋ํ๊ณ ํ์ผ URL์์ osm์ openstreetmap์ผ๋ก ๋ณ๊ฒฝํ๋ ๋ฐ https๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค(
http://{s}.tile.osm.org/{z}/{x}/{y}.png
->https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
).