ProfessionalWiki / ProfessionalWiki/Maps
External map control
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 78
- Forks
- 65
- Avg merge
- 9h 17m
- Merged PRs (30d)
- 6
Description
I have been looking for a way to externally control a leaflet map. That is I have a list of addresses and I want to have a "show on map" link on every line. I wanted to share my solution and ask if there is a better way to do it.
/* this structure is assumed (as provided by Template:ShowOnMap):
<span class=".Maplink"><a href="URL#divId">LINKTEXT</a><span class="coords"><span class="coordvalues">lat,long</span></span></span>
The map has to be enclosed by a div with id divId. It works as link target on page and to identify the map.
*/
$(".Maplink a").on('click', function() {
divId = $(this).attr("href").split('#').pop();
for (var i = 0; i < mapsLeafletList.length; i++) {
/* check if this map is enclosed by div divId */
if ($(mapsLeafletList[i][0]).parents("#"+divId).length) {
coords = $(this).parent().find("span.coordvalues").html();
var latLng=L.latLng(coords.split(","));
mapsLeafletList[i].map.flyTo(latLng, 16);
}
}
});
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the external click handler and the mapsLeafletList entry point shown in the issue, then inspect how embedded Leaflet maps expose controls. Determine whether the extension already provides a supported way to target a map and move it to coordinates. Done should be a clear, documented approach for externally controlling the intended map.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100