Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for simple text or numbers on markers #31

Open
chriszrc opened this issue May 9, 2017 · 4 comments
Open

Add option for simple text or numbers on markers #31

chriszrc opened this issue May 9, 2017 · 4 comments

Comments

@chriszrc
Copy link

chriszrc commented May 9, 2017

That kind of support was added to the extra markers plugin:

https://github.com/coryasilva/Leaflet.ExtraMarkers

But clearly vector markers are the way to go-

@rajivhbk
Copy link

It's not that difficult to implement this for yourself. I achieved this by modifying few lines of code somewhere around line 182 . Modify this according to your needs.

div.innerHTML = '<svg width="' + options.iconSize[0] + 'px" height="' + options.iconSize[1] + 'px" viewBox="' + options.viewBox + '" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="' + pin_path + '" fill="' + options.markerColor + '"></path><text x="'+ options.iconTextPosition[0]+'" y="'+ options.iconTextPosition[1] +'" style="font-weight: 600" text-anchor="middle" font-family="\'PT Sans\'" font-size="'+ options.iconTextSize +'" fill="white">'+ options.iconText +'</text></svg>';

and at line 140 you will find var iconOptions. again modify this according to your needs.

var iconOptions = { iconSize: [30, 50], iconAnchor: [15, 50], popupAnchor: [2, -40], shadowAnchor: [39, 45], shadowSize: [54, 51], iconText: '', iconTextPosition: [15, 25], iconTextSize: 12, className: 'vector-marker', prefix: 'fa', spinClass: 'fa-spin', extraIconClasses: '', extraDivClasses: '', icon: 'home', markerColor: 'blue', iconColor: 'white', viewBox: '0 0 32 52' };

@nils-v
Copy link

nils-v commented Sep 16, 2017

I failed trying a similar modification; I want to add a directive to the innerHTML by adding an option svgDefs at line 140 and using options.svgDefs in line 182. I added the svgDefs option on creating the Icon:
icon: L.VectorMarkers.icon( { iconSize: [35,50], icon: 'bank' , prefix: 'fa', markerColor: 'red', iconColor: '#278c11', svgDefs: '<defs><radialGradient + ' r="70%" fx="50%" fy="30%">' + '<stop offset="0%" stop-color="white" />' + '<stop offset="100%" stop-color="black'" /></radialGradient></defs>' })
but the options.svgDefs ist not defined.
What is missing?

@nils-v
Copy link

nils-v commented Sep 16, 2017

Problem solved! It worked that way, I had only a build problem. I'll fork the project to imnplement the changes.

@rajivhbk
Copy link

Good to know it worked for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants