में मार्कर घुमाएं मैं पुस्तिका में मार्कर कैसे घुमा सकता हूं? मेरे पास घूर्णन कोण के साथ बहुत सारे मार्कर होंगे।पत्रक
मैं Leaflet on GitHub पर runanet/coomsie से इस समाधान की कोशिश की है, लेकिन कुछ भी मेरे मार्कर के साथ होता है:
L.Marker.RotatedMarker= L.Marker.extend({
_reset: function() {
var pos = this._map.latLngToLayerPoint(this._latlng).round();
L.DomUtil.setPosition(this._icon, pos);
if (this._shadow) {
L.DomUtil.setPosition(this._shadow, pos);
}
if (this.options.iconAngle) {
this._icon.style.WebkitTransform = this._icon.style.WebkitTransform + ' rotate(' + this.options.iconAngle + 'deg)';
this._icon.style.MozTransform = 'rotate(' + this.options.iconAngle + 'deg)';
this._icon.style.MsTransform = 'rotate(' + this.options.iconAngle + 'deg)';
this._icon.style.OTransform = 'rotate(' + this.options.iconAngle + 'deg)';
}
this._icon.style.zIndex = pos.y;
},
setIconAngle: function (iconAngle) {
if (this._map) {
this._removeIcon();
}
this.options.iconAngle = iconAngle;
if (this._map) {
this._initIcon();
this._reset();
}
}
});
var rotated = new L.Marker.RotatedMarker([63.42, 10.39]);
rotated.setIconAngle(90);
rotated.addTo(map);
कोई अन्य विचार या समाधान? (विंडोज़ पर फ़ायरफ़ॉक्स 16 के साथ परीक्षण।)
आपने उत्तर में मुझे बहुत मदद की, केवल एक मुद्दा छोड़ा: असल में मेरा आइकन पहले ड्रॉ पर घूमता नहीं है। "SetIconAngle" के साथ क्लिक पर कोण को बदलने का प्रयास किया, यह परीक्षण कोड में आपके साथ बहुत अच्छा काम करता है। लेकिन मेरा आइकन एंगल पहली ड्रॉ पर क्यों उपयोग नहीं किया जाता है? – sindrejh
ने मार्कर से इस क्रिया को विस्तारित किया है ताकि आइकन शुरू करने से आइकन को घुमाने के लिए वर्कअराउंड के रूप में। – sindrejh
सहायक कोड और उत्तर। मैंने इस समाधान को लागू किया है - हालांकि मेरे पास एक मुद्दा है। जब भी मैं मानचित्र पर ज़ूम इन/आउट करता हूं, मार्करों का घूर्णन 0 कोण पर रीसेट हो जाता है। क्या आपके पास यही समस्या है? क्या नक्शा ज़ूम इन/आउट होने पर मार्कर अपने कोण को रीसेट करेगा? –