私はしばらくこの作業を行っており、最新のopenlayers(これを書いている時点でのバージョン3)の情報を見つけることができないようです...openlayersの機能の場所を設定する
私は実際に私の髪を引っ張っています!
地図上の特定の場所に機能(ol.feature)を配置する方法を知っておく必要があります。
私は関数サーバー側で緯度と経度を抽象化し、それらをテンプレートタグを使用してjsコードに渡しています。それは海の真ん中にあるアフリカの沖に置いている瞬間
... これまでは私のコード。あなたは私が知っているより多くの情報が必要な場合は
<html lang="en">
<head>
<link rel="stylesheet" href="http://openlayers.org/en/v3.16.0/css/ol.css" type="text/css">
<style>
.map {
height: 500px;
width: 100%;
}
</style>
<script src="http://openlayers.org/en/v3.16.0/build/ol.js" type="text/javascript"></script>
<title>pickup point selection</title>
</head>
<body>
<h2>Choose your pickup point</h2>
<div id="map" class="map"></div>
<script type="text/javascript">
var customerCoordinates = new ol.geom.Point([ {{longitude}}, {{latitude}} ]);
var iconFeature = new ol.Feature({
geometry: customerCoordinates,
name: '{{postcode}}'
});
iconFeature.
var iconStyle = new ol.style.Style({
text: new ol.style.Text({
text: '\uf015',
font: 'normal 50px FontAwesome',
textBaseline: 'Bottom',
fill: new ol.style.Fill({
color: 'black',
})
})
});
iconFeature.setStyle(iconStyle);
iconFeature.setG
var vectorSource = new ol.source.Vector({
features: [iconFeature]
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource});
var rasterLayer = new ol.layer.Tile({
source: new ol.source.OSM()});
var map = new ol.Map({
layers: [rasterLayer, vectorLayer],
target: document.getElementById('map'),
view: new ol.View({
center: ol.proj.fromLonLat([ {{longitude}}, {{latitude}} ]),
zoom: 17
})
});
</script>
</body>
</html>
すべてのヘルプは非常に
をいただければ幸いです!この
へ
var customerCoordinates = new ol.geom.Point([ {{longitude}}, {{latitude}} ])
はおそらく、座標[0,0] –