大佬教程收集整理的这篇文章主要介绍了如何使用传单和jQuery Birdseye突出显示点击标记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用jQuery Birdseye(http://ajb.github.io/jquery-birdseye/)来学习并获得某种交互式地图.我将编号的标记图标更改为编号的标记精灵.精灵工作正常,位置由针脚控制(0 =蓝色,1 =突出显示,蓝色,2 =橙色,3 =突出显示橙色)和内部“状态” l.marker.我知道new_marker点击功能仅将目标标记设置为突出显示.无法找到重现该功能的解决方案,如同在foursquare地图上点击时突出显示标记.请指出我正确的方向.
l.numberedDivIcon = l.Icon.extend({ options: { sprite:"images/mappin-sprite.png",number: '',iconSize: new l.Point(29,39),iconAnchor: new l.Point(15,37),gridSize: new l.Point(35,45),popupAnchor: new l.Point(0,-33),shadowUrl:"images/mappin-shadow.png",shadowSize:new l.Point(29,15),shadowAnchor:new l.Point(15,10),state: '' },createIcon: function () { var div = document.createElement('div'); div.style.BACkgroundImage="url("+this.options.sprite+")"; div.className="leaflet-marker-icon"; div.style.marginLeft=-this.options.iconAnchor.x+"px"; div.style.marginTop=-this.options.iconAnchor.y+"px"; var b=this.options.gridSize||this.iconSize; var c=this.options['number'] || ''; var cd=this.options['state'] || ''; var d= this.options.gridSize.y+this.options.iconSize.y+cd; div.style.BACkgroundPosition=-(c*b.x+(b.x-this.options.iconSize.X)/2)+"px "+-(d*b.y+(b.y-this.options.iconSize.y)/2)+"px"; this._setIconStyles(div,'icon'); return div; },//you Could change this to add a shadow like in the normal marker if you really wanted createShadow: function () { var a=this.options.shadowSize; var img = this._createImg(this.options['shadowUrl']); img.style.marginLeft=-this.options.shadowAnchor.x+"px"; img.style.marginTop=-this.options.shadowAnchor.y+"px"; img.style.width=a.x+"px",img.style.height=a.y+"px"; img.className="leaflet-marker-icon"; return img; } });
processResults = function(results) { var marker,_i,_len; setTings.results_el.html(''); for (_i = 0,_len = markers.length; _i < _len; _i++) { marker = markers[_i]; map.removeLayer(marker); } if (results.length > 0) { return $(results).each(function(key,result) { var new_marker; if (result.women == truE) { var pin = 2; } else { var pin = 0; } new_marker = l.marker(setTings.response_params_latlng(result),{ icon: new l.numberedDivIcon({ number: key,state: pin }) }); function setHighlightIcon(E) { new_marker = e.target; var pinSELEcted = pin+1; new_marker.setIcon(new l.numberedDivIcon({number: key,state:pinSELEcteD})); new_marker.setZIndexOffset(+100) } function setDefaultIcon() { var pindeSELEcted = pin; new_marker.setIcon(new l.numberedDivIcon({number: key,state: pindeSELEcteD})); } new_marker.on({ 'click': setHighlightIcon }); markers.push(new_marker.addTo(map)); return setTings.results_el.append(setTings.results_template(key,result)); }) } else { return setTings.results_el.append(setTings.no_results_template()); } }
// Default map var map = l.map('map',{ 'center': [0,0],'zoom': 0,'layers': [ l.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ 'attribution': 'Map data © OpenStreetMap contributors' }) ] }); // Custom icon class without iconUrl var customIcon = l.Icon.extend({ options: { shadowUrl: 'http://leafletjs.com/docs/images/leaf-shadow.png',iconSize: [38,95],shadowSize: [50,64],iconAnchor: [22,94],shadowAnchor: [4,62],popupAnchor: [-3,-76] } }); // Some positions for creaTing markers var positions = [ [0,120],[0,60],-60],-120] ]; // Function for getTing new default icon function getDefaultIcon() { return new customIcon({ iconUrl: 'http://leafletjs.com/docs/images/leaf-green.png' }); } // Function for getTing new highlight icon function getHighlightIcon() { return new customIcon({ iconUrl: 'http://leafletjs.com/docs/images/leaf-red.png' }); } // Variable to keep track of highlighted marker var highlight = null; // Function for removing highlight function removeHighlight() { // check for highlight if (highlight !== null) { // Set default icon highlight.setIcon(getDefaultIcon()); // Unset highlight highlight = null; } } // Loop over positions positions.forEach(function(position) { // Create new marker var marker = l.marker(position,{ // Set default icon icon: getDefaultIcon() }) // Marker click marker.on('click',function() { // Remove highlight removeHighlight(); // Set highlight icon marker.setIcon(getHighlightIcon()); // Assign highlight highlight = marker; }); // Add marker to map; marker.addTo(map); }); // Add map click handler,remove highlight map.on('click',removeHighlight);
body { margin: 0; } html,body,#map { height: 100%; }
<link rel="stylesheet" href="//cdnjs.cloudFlare.com/ajax/libs/leaflet/0.7.3/leaflet.css" data-require="leaflet@0.7.3" data-semver="0.7.3" /> <link rel="stylesheet" href="style.css" /> <div id="map"></div> <script type="text/javascript" src="//cdnjs.cloudFlare.com/ajax/libs/leaflet/0.7.3/leaflet.js" data-require="leaflet@0.7.3" data-semver="0.7.3"></script>
以下是Plunker:http://plnkr.co/edit/K9XmMz?p=preview的工作示例
以上是大佬教程为你收集整理的如何使用传单和jQuery Birdseye突出显示点击标记全部内容,希望文章能够帮你解决如何使用传单和jQuery Birdseye突出显示点击标记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。