2
サークルはありますが、ページを読み込むと常に表示されます。私はmap.Itをクリックすると、このサークルが表示されます円は同じ場所に残り、移動しない場所にこだわりました。私はマップをクリックすると表示されたい誰も助けることができますか?それとも、ここ地図上のMouseClickイベントとOpenLayersを使用して円を表示する2
function updateIcon(f) {
f.style.externalGraphic = "marker.png";
vector.drawFeature(f);
}
options = {
div: "map",
zoom: 2,
center: [0, 0],
layers: [
new OpenLayers.Layer.OSM()
]
};
map = new OpenLayers.Map(options);
vector = new OpenLayers.Layer.Vector();
map.addLayer(vector);
var point1 = new OpenLayers.Geometry.Point(0,0);
var point2 = new OpenLayers.Geometry.Point(1000000, 1000000);
var point3 = new OpenLayers.Geometry.Point(2000000, 2000000);
var radius = $("#amount").val();
var mycircle = OpenLayers.Geometry.Polygon.createRegularPolygon(point2,radius,40,0);
var featurecircle = new OpenLayers.Feature.Vector(mycircle);
// var selected_polygon_style = {
// strokeWidth: 5,
// strokeColor: '#ff0000'
// // add more styling key/value pairs as your need
// };
// featurecircle.style = selected_polygon_style;
marker1 = new OpenLayers.Feature.Vector(point1, null, {
externalGraphic: "marker.png",
graphicWidth: 32,
graphicHeight: 32,
fillOpacity: 1
});
marker1.style = { display: 'none' };
marker2 = new OpenLayers.Feature.Vector(point2, null, {
externalGraphic: "marker.png",
graphicWidth: 32,
graphicHeight: 32,
fillOpacity: 1
});
marker3 = new OpenLayers.Feature.Vector(point3, null, {
externalGraphic: "marker.png",
graphicWidth: 32,
graphicHeight: 32,
fillOpacity: 1
});
vector.addFeatures([marker1, marker2, marker3, featurecircle]);
$("#slider-range-max").slider({
range: "max",
min: 1000000,
max: 3000000,
value: 1000000,
slide: function(event, ui) {
$("#amount").val(ui.value);
radius = $("#amount").val();
vector.removeFeatures([featurecircle]);
var mycircle = OpenLayers.Geometry.Polygon.createRegularPolygon
(
point2,
radius,
40,
0
);
featurecircle = new OpenLayers.Feature.Vector(mycircle);
vector.addFeatures([featurecircle]);
console.log(radius);
}
});
$("#amount").val($("#slider-range-max").slider("value"));
$(radius).val($("#slider-range-max").slider("value"));
<p>
<label for="amount">Minimum number</label>
<input type="text" id="amount" value="1000000" style="border:0; color:#f6931f; font-weight:bold;">
</p>
<div id="slider-range-max"></div>
<div id="map" style="width:600px;height:600px;"></div>
あなたは仲間セーバー生活しています。あなたを愛してます。私はブラウザでそれを走らせましたが、 "Run code Snippet"に現れる同じエラーに直面しています。これは何ですか ?何か考えてみませんか? –
@tousifNoorはここにファイルiamはhttp://pastebin.com/Z47a9WD1を使用しています –
ありがとうございます:)。デフォルトでは、サークルが表示されるだけです。私は地図をクリックしたときにのみ消えて現れませんか?クリック後の最初の出現を意味しますか? –