add core functions to create a generic marker icon, of a specified colour.
use it for the new portal distance current location marker, and search result marker
This commit is contained in:
parent
e03bbf50f1
commit
badcdbdb18
@ -137,15 +137,8 @@ window.search.Query.prototype.onResultSelected = function(result, ev) {
|
||||
result.layer = L.layerGroup();
|
||||
|
||||
if(result.position) {
|
||||
var markerTemplate = '@@INCLUDESTRING:images/marker-icon.svg.template@@';
|
||||
L.marker(result.position, {
|
||||
icon: L.divIcon({
|
||||
iconSize: new L.Point(25, 41),
|
||||
iconAnchor: new L.Point(12, 41),
|
||||
html: markerTemplate.replace(/%COLOR%/g, 'red'),
|
||||
className: 'leaflet-iitc-search-result-icon',
|
||||
}),
|
||||
title: result.title,
|
||||
createGenericMarker(result.position, 'red', {
|
||||
title: result.title
|
||||
}).addTo(result.layer);
|
||||
}
|
||||
|
||||
|
@ -440,6 +440,32 @@ window.clampLatLngBounds = function(bounds) {
|
||||
return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) );
|
||||
}
|
||||
|
||||
window.getGenericMarkerSvg = function(color) {
|
||||
var markerTemplate = '@@INCLUDESTRING:images/marker-icon.svg.template@@';
|
||||
|
||||
return markerTemplate.replace(/%COLOR%/g, color);
|
||||
}
|
||||
|
||||
window.getGenericMarkerIcon = function(color,className) {
|
||||
return L.divIcon({
|
||||
iconSize: new L.Point(25, 41),
|
||||
iconAnchor: new L.Point(12, 41),
|
||||
html: getGenericMarkerSvg(color),
|
||||
className: className || 'leaflet-iitc-divicon-generic-marker'
|
||||
});
|
||||
}
|
||||
|
||||
window.createGenericMarker = function(ll,color,options) {
|
||||
options = options || {};
|
||||
|
||||
var markerOpt = $.extend({
|
||||
icon: getGenericMarkerIcon(color || '#a24ac3')
|
||||
}, options);
|
||||
|
||||
return L.marker(ll, markerOpt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fix Leaflet: handle touchcancel events in Draggable
|
||||
L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown;
|
||||
|
@ -85,19 +85,9 @@ window.plugin.distanceToPortal.setLocation = function() {
|
||||
window.plugin.distanceToPortal.currentLoc = map.getCenter();
|
||||
}
|
||||
|
||||
window.plugin.distanceToPortal.currentLocMarker = createGenericMarker (window.plugin.distanceToPortal.currentLoc,'#444',{draggable:true});
|
||||
|
||||
var markerTemplate = '@@INCLUDESTRING:images/marker-icon.svg.template@@';
|
||||
window.plugin.distanceToPortal.currentLocMarker = L.marker(window.plugin.distanceToPortal.currentLoc,{
|
||||
icon: L.divIcon({
|
||||
iconSize: new L.Point(25, 41),
|
||||
iconAnchor: new L.Point(12, 41),
|
||||
html: markerTemplate.replace(/%COLOR%/g, '#444'),
|
||||
className: 'leaflet-iitc-distance-to-portal-location'
|
||||
}),
|
||||
draggable: true,
|
||||
});
|
||||
|
||||
window.plugin.distanceToPortal.currentLocMarker.on('dragend', function(e) {
|
||||
window.plugin.distanceToPortal.currentLocMarker.on('drag', function(e) {
|
||||
window.plugin.distanceToPortal.currentLoc = window.plugin.distanceToPortal.currentLocMarker.getLatLng();
|
||||
|
||||
localStorage['plugin-distance-to-portal'] = JSON.stringify({lat:window.plugin.distanceToPortal.currentLoc.lat, lng:window.plugin.distanceToPortal.currentLoc.lng});
|
||||
|
Loading…
x
Reference in New Issue
Block a user