|
640 | 640 | latlng, latlngs, coordinates, member, members, linestrings; |
641 | 641 |
|
642 | 642 | coordsToLatLng = coordsToLatLng || this.coordsToLatLng; |
643 | | - var pointOptions = { opacity: vectorOptions.opacity ? vectorOptions.opacity : null, |
644 | | - icon: L.icon( |
645 | | - { iconUrl: vectorOptions.imagePath+"marker-icon.png", |
646 | | - iconRetinaUrl: vectorOptions.imagePath+"marker-icon-2x.png", |
647 | | - shadowUrl: vectorOptions.imagePath+"marker-shadow.png", |
648 | | - iconSize: [25, 41], |
649 | | - iconAnchor: [12, 41], |
650 | | - popupAnchor: [1, -34], |
651 | | - shadowSize: [41, 41] |
652 | | - })}; |
653 | 643 |
|
654 | 644 | var cs = geometry.getAttribute("cs") || nativeCS; |
655 | 645 |
|
|
658 | 648 | coordinates = []; |
659 | 649 | geometry.getElementsByTagName('coordinates')[0].textContent.split(/\s+/gim).forEach(M.parseNumber,coordinates); |
660 | 650 | latlng = coordsToLatLng(coordinates, cs, zoom, this.options.projection); |
661 | | - return pointToLayer ? pointToLayer(mapml, latlng) : |
662 | | - new L.Marker(latlng, pointOptions); |
| 651 | + return pointToLayer ? pointToLayer(mapml, latlng) : M.svgMarker(latlng, vectorOptions); |
663 | 652 |
|
664 | 653 | case 'MULTIPOINT': |
665 | 654 | coordinates = []; |
666 | 655 | geometry.getElementsByTagName('coordinates')[0].textContent.match(/(\S+ \S+)/gim).forEach(M.splitCoordinate, coordinates); |
667 | 656 | latlngs = this.coordsToLatLngs(coordinates, 0, coordsToLatLng, cs, zoom); |
668 | 657 | var points = new Array(latlngs.length); |
669 | 658 | for(member=0;member<points.length;member++) { |
670 | | - points[member] = new L.Marker(latlngs[member],pointOptions); |
| 659 | + points[member] = M.svgMarker(latlngs[member], vectorOptions); |
671 | 660 | } |
672 | 661 | return new L.featureGroup(points); |
673 | 662 | case 'LINESTRING': |
|
5163 | 5152 | return new Crosshair(options); |
5164 | 5153 | }; |
5165 | 5154 |
|
| 5155 | + var SVGMarker = L.Path.extend({ |
| 5156 | + options: { |
| 5157 | + fillColor: '#2e91bf', |
| 5158 | + color: '#ffffff', |
| 5159 | + fill: true, |
| 5160 | + className: "mapml-marker", |
| 5161 | + fillOpacity: 1, |
| 5162 | + weight: 1, |
| 5163 | + }, |
| 5164 | + |
| 5165 | + initialize: function (latlng, options) { |
| 5166 | + L.setOptions(this, options); |
| 5167 | + this._latlng = L.latLng(latlng); |
| 5168 | + }, |
| 5169 | + |
| 5170 | + _project: function () { |
| 5171 | + this._point = this._map.latLngToLayerPoint(this._latlng); |
| 5172 | + }, |
| 5173 | + |
| 5174 | + _update: function () { |
| 5175 | + if (!this._map) return; |
| 5176 | + this._path.setAttribute("d", this.defineMarker(this._point)); |
| 5177 | + }, |
| 5178 | + |
| 5179 | + getLatLngs: function () { |
| 5180 | + return this._latlng; |
| 5181 | + }, |
| 5182 | + |
| 5183 | + getCenter: function () { |
| 5184 | + return this._latlng; |
| 5185 | + }, |
| 5186 | + |
| 5187 | + defineMarker: function (p) { |
| 5188 | + return `M${p.x} ${p.y} L${p.x - 12.5} ${p.y - 30} C${p.x - 12.5} ${p.y - 50}, ${p.x + 12.5} ${p.y - 50}, ${p.x + 12.5} ${p.y - 30} L${p.x} ${p.y}z`; |
| 5189 | + }, |
| 5190 | + |
| 5191 | + }); |
| 5192 | + |
| 5193 | + var svgMarker = function (latlng, options) { |
| 5194 | + return new SVGMarker(latlng, options); |
| 5195 | + }; |
| 5196 | + |
5166 | 5197 | /* |
5167 | 5198 | * Copyright 2015-2016 Canada Centre for Mapping and Earth Observation, |
5168 | 5199 | * Earth Sciences Sector, Natural Resources Canada. |
|
5781 | 5812 | M.Crosshair = Crosshair; |
5782 | 5813 | M.crosshair = crosshair; |
5783 | 5814 |
|
| 5815 | + M.SVGMarker = SVGMarker; |
| 5816 | + M.svgMarker = svgMarker; |
| 5817 | + |
5784 | 5818 | }(window)); |
5785 | 5819 |
|
5786 | 5820 | }()); |
0 commit comments