Add marker to multiple layer groups - leaflet

I have created a map with leafletjs using StyledLayerControl and markercluster:
https://www.wiva.at/v2/basemap-kartentest/
Each marker represents a research project that fits in one category (=layergroup).
Unfortunately I have some projects that fall into three categories (like the very south one near the city LEIBNITZ close to GRAZ). So far this one project is represented as three markers, and I got the feedback this confuses especially in the spiderfied view.
I've come across an issue, when assigning my marker to a variable and then adding the variable to multiple layergroups that unselecting one layergroup makes the marker disappear in the other layer groups as well.
So is there any chance to represent such a project as ONE marker but appearing in multiple layer groups?
If the link above is not sufficient I can add my code (but I'm afraid it's kind of messy).
Thanks for any hint.
EDIT:
So far I add my marker simply like that:
//Green Industry projects
//new (running) projects
var industry_new = new L.LayerGroup();
//Renewable Gasfield, laufend, Wiva, ONLINE
L.marker([46.753278, 15.586361], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>Renewable Gasfield</span></p><b>Projektleitung:</b> Energie Steiermark<br /><b>Standort:</b> Gabersdorf<br /><b>Kategorie:</b> Grüne Industrie<br /><b>Status:</b> laufend<br /><p>Ganzheitlicher Power-to-Gas Ansatz, bei dem aus erneuerbarem Strom durch Elektrolyse grüner Wasserstoff erzeugt wird und eine zweistufige katalytische Methanisierung im großen Maßstab für eine nachhaltige Energieversorgung in den Bereichen Energie, Mobilität und Industrie vereint.</p><a href='https://www.wiva.at/v2/portfolio-item/renewable-gasfield/'>Details...</a>");
//HyTechbasis 4 WIVA, laufend, Wiva, ONLINE
L.marker([48.155278, 14.048056], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>HyTechbasis 4 WIVA</span></p><b>Projektleitung:</b> FRONIUS INTERNATIONAL GmbH<br /><b>Standort:</b> Thalheim<br /><b>Kategorie:</b> Grüne Industrie<br /><b>Status:</b> laufend<br /><p>Hydrogen Technology Basis for WIVA</p><a href='https://www.wiva.at/v2/portfolio-item/hytechbasis-4-wiva-hydrogen-technology-basis-for-wiva/'>Details...</a>");
//Co2EXIDE WIVA, laufend, Wiva, ONLINE
L.marker([48.33826938809515, 14.317320611066839], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>CO2EXIDE</span></p><b>Projektleitung:</b> (österreichischer Partner) Energieinstitut an der JKU Linz<br /><b>Standort:</b> AGH Krakau Demo-Anlage<br /><b>Kategorie:</b> Grüne Industrie<br /><b>Status:</b> laufend<br /><p>CO2-basierte Elektrosynthese von Ethylen Oxiden</p><a href='http://www.co2exide.eu/'>Details...</a>");
//CORALIS WIVA, laufend, Wiva, ONLINE
L.marker([48.288029, 14.324497], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>CORALIS</span></p><b>Projektleitung:</b> Fundación CIRCE / Öst. Partner: Energieinstitut an der JKU Linz<br /><b>Standort:</b> Linz<br /><b>Kategorie:</b> Grüne Industrie<br /><b>Status:</b> laufend<br /><p>Erfahrungen im Bereich der Industriesymbiose zusammenstellen</p><a href='https://cordis.europa.eu/project/id/958337'>Details...</a>");
//UpHY, laufend, Wiva, ONLINE
L.marker([48.14735053624901, 16.492216234765525], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>UpHy I</span></p><b>Projektleitung:</b> OMV<br /><b>Standort:</b> Wien<br /><b>Kategorie:</b> Grüne Mobilität<br /><b>Status:</b> laufend<br /><p>Im Project UpHy I wird die Basis für die Demonstration der Wertschöpfungskette für die grüne H2- Mobilität von der Produktion in einer Elektrolyse über die Logistik bis zur 350 bar Betankungsinfrastruktur für eine kommerziell betriebene Buslinie mit Brennstoffzellenantrieb entwickelt.</p><a href='https://www.wiva.at/v2/portfolio-item/uphy-upscaling-of-green-hydrogen-for-mobility-and-industry/'>Details...</a>");
//Underground Sun.Conversion, laufend, Wiva-Netzwerk
L.marker([48.028889, 13.691944], {icon: industryIcon} ).addTo(industry_new).bindPopup("<p><span style='font-size:12pt;font-weight:bold; color:#0099b8;'>Underground Sun.Conversion</span></p><b>Projektleitung:</b> RAG Austria AG<br /><b>Standort:</b> Pilsbach<br /><b>Kategorie:</b> Grüne Industrie<br /><b>Status:</b> abgeschlossen<br /><p>Chemical storage of renewable energy in porous subsurface reservoirs with exemplary testbed</p><a href='https://www.underground-sun-conversion.at/'>Details...</a>");
I do that for each layer group. Probably this is not the best way, but for me as a java and leaflet beginner the easiest way and I was just very happy everything worked out so far ;-)

Unfortunately that is an unresolved UX issue. The main issue is that in some use cases, you want an OR filter (sounds like it would be your case, since your Markers are duplicated in each group where they fit the associated category); and in others, you want an AND filter...
So if you want to populate your map with all Markers that fit at least one selected category (i.e. implement an OR filter), a possible solution could be to use "dummy" empty Layer Groups for your selection control, clear and re-populate the map with relevant Markers whenever the user selection changes.
For example, if you have the map "overlayadd/remove" events:
// "Dummy" layers to be used in selection control
const dummy1 = L.layerGroup();
const dummy2 = L.layerGroup();
// Actual categories with possibly common Markers
const category1 = L.layerGroup([markerA, markerB]);
const category2 = L.layerGroup([markerA, markerC]);
// Intermediate group to easily clear map content
const content = L.layerGroup().addTo(map);
map.on("overlayadd overlayremove", () => {
// Step 1: remove all content
content.clearLayers();
// Step 2: re-add layers that fit at least one selection
if (map.hasLayer(dummy1)) {
category1.addTo(content)
}
if (map.hasLayer(dummy2)) {
category2.addTo(content)
}
// etc.
});
In case you use Leaflet.markercluster, you can simply use it as the content variable in above snippet.
You also have to create only 1 Marker per project, no longer duplicate them for each category. In normal use cases, this should be avoided, but here we specifically handle this case. For example if Marker A matches categories 1 and 2, you can do:
L.marker(latLngA).addTo(category1).addTo(category2);

Related

Saving 2 versions of an entity at the same time

I'm currently trying to implement a CRUD-Application für Orders/Articles in JSF/Primefaces.
Whenever I create a new version of an article I want to merge the old entity with a different status and save the new entity populated by form input with a new ID.
This is the relationship between Article and OrderLine:
The Article Entity has the following field:
#OneToMany(cascade = CascadeType.ALL, mappedBy = "fkArticleID")
#XmlTransient
private Collection<OrderLine> orderLineCollection;
This is the method that updates/saves the new Entity:
public void edit(Article article) throws OptimisticLockException {
/* PK des Auftrags/der Auftragsposition speichern um die Suche zu vereinfachen */
int articleID = article.getArticleID();
/**
*
* Falls sich article im Zustand "detached" befindet, werden in
* attachedArticle die aktuellen Daten aus der DB geladen.
*
* Falls sich orderLine im Zustand "managed" befindet, werden in
* attachedOrderLine die Daten aus dem PersistenceContext geladen. Dies
* ist notwendig, da nur Datensätze für Entities gesperrt werden können
* die sich im Zustand "managed" befinden.
*
*/
Article attachedArticle = em.find(Article.class, articleID, LockModeType.OPTIMISTIC);
/* Prüfen ob der Artikel noch in der Datenbank vorhanden ist */
if (attachedArticle != null) {
/* Laden des aktuellsten Datensatzes aus der Datenbank */
Article latestVersionArticle = findLatestVersion(articleID);
/* Anhand der Version wird geprüft ob die bearbeiteten Daten noch konsistent mit dem Zustand der Datenbank sind */
if (latestVersionArticle.getVersion() == article.getVersion()) {
/**
* Schreibt den bearbeiteten Artikel zurück in die Datenbank,
* Versionsnummer wird am Ende der Transaktion automatisch
* inkrementiert (optimistische Sperre)
*/
latestVersionArticle.setArticleStatus(ArticleStatus.GESPERRT);
em.merge(latestVersionArticle);
/**
* Erstellt einen neuen Artikel mit den eingegebenen Daten und
* dem Status Freigegeben.
*/
article.setArticleStatus(ArticleStatus.FREIGEGEBEN);
article.setOrderLineCollection(null);
em.persist(article);
} else {
/* OptimisticLockException werfen falls die Daten des Auftrags nicht mehr konsistent sind */
throw new OptimisticLockException(article);
}
} else {
throw new OptimisticLockException(article);
}
}
Everything seems to work fine at first.. however the newer Version of the article seems to automatically create another OrderLine which shows up in the existing Order.. so whenever I "update" an article, while the newer version is created, it is also creating another OrderLine.. I suspect the fault lies with the #OneToMany field in the Article-Entity.. I'm trying to set the orderLineCollection to null before persisting but it doesnt seem to work.
You have to remove cascading on the orderLineCollection.
If you persist an article, you'll always get duplicates of the existing orderLines.
Please also consider to remove the bidirectional relationship between Article and OrderLine. Usually you only need a unidirectional relationship from OrderLine to Article. If you need all OrderLines for an article, you can use a NamedQuery.

Add alt attribute to ALL links in Typo3

I'm currently making a website accessible. Currently, there are only the title attributes defined of each link. For maximum compatibility with screen readers, I need to have the alt and the title.
Is there a way to add to each link the alt attribute with the value of the title? Best would be typoscript.
Another problem is, that the site is online and frequently visited. It has to be a method which is 100% working.
found here : http://typo3-4-newbies.blogspot.co.at/2014/03/image-alt-text-so-hinterlegen-sie-einen.html
// Löscht die Standard-Konfiguration des Alt-Textes
tt_content.image.20.1.altText >
// Neuaufbau als TEXT-Objekt
tt_content.image.20.1.altText = TEXT
tt_content.image.20.1.altText {
// zusätzliches Objekt zur Fallunterscheidung leer/befüllt
// (zugegeben: erst nach längerem herumprobieren war das die finale Lösung)
cObject = TEXT
// Das Objekt erhält den Wert aus dem Feld "alternative Text",
// den Sie direkt beim Bild eintragen können
cObject.field = altText
// Wenn kein Alt-Text hinterlegt wurde, wird ein TEXT-Objekt erzeugt
ifEmpty.cObject = TEXT
ifEmpty.cObject {
// Ich ersetze nun Teile des Original-Dateinamens
// Da ich es übersichtlich mag, teile ich mir meine Funktion ein wenig auf
replacement {
10 {
// Sucht alle Werte zwischen "/" und entfernt diese
search = /\/(.*)\//
useRegExp = 1
replace =
}
15 {
// Danach entferne ich die Dateiendung
// Somit steht nur noch der reine Name der Datei da
search = /^(.*)\.(.*)/
useRegExp = 1
replace = $1
}
20 {
// zuletzt lösche ich die voranstehenden Punkte,
// sollten diese von TYPO3 gesetzt worden sein
search = ..
replace =
}
}
// Den Wert (hier der Dateiname plus Pfad) beziehe ich aus dem Feld "image" des Inhaltselements
field = image
// Da im Feld "image" die Bilder durch Komma getrennt in der Datenbank abgespeichert werden,
// führe ich einen Optionsplit mit Komma als Trennzeichen durch. Damit kann ich jedes einzelne Bild entsprechend bearbeiten.
// Tun Sie dies nicht, haben aber mehrere Bilder, so würde der Alt-Text des letzten Bildes bei allen anderen angezeigt werden
split.token.char = 44
// Gibt je das aktuelle Bild zurück
split.returnKey.data = register : IMAGE_NUM_CURRENT
}
}
// Vererbung der neuen Alt-Text Definitionen auf das Inhaltselement "Text mit Bild"
tt_content.textpic.20.1.altText.ifEmpty.cObject < tt_content.image.20.1.altText.ifEmpty.cObject

geocode don't show subpremise address Brazil

how to collect room number information on a building in the google geocode?
in my search don't show. SUBPREMISE
example address: rua joao samaha 1385, sala 403 bl 02 sao joao batista, belo horizonte, MG, Brazil.
https://maps.googleapis.com/maps/api/geocode/json?address=
I'm a developer at SmartyStreets, an international address verification API provider. Here's the component information that we have on that address:
[
{
// preceding data omitted
"components":{
"administrative_area":"MG",
"building":"Bloco 02",
"dependent_locality":"São João Batista (Venda Nova)",
"country_iso_3":"BRA",
"locality":"Belo Horizonte",
"postal_code":"31520-100",
"postal_code_short":"31520-100",
"premise":"1385",
"premise_number":"1385",
"thoroughfare":"Rua João Samaha",
"thoroughfare_name":"Joao Samaha",
"thoroughfare_type":"Rua",
"building_leading_type":"Bloco",
"sub_building_type":"Sala",
"sub_building_number":"403"
},
// remaining data omitted
}
]
Does that information help?
https://smartystreets.com/docs/international#components

What is wrong with my pattern for preg_replace?

I have a variable containing the following html code
Bloom's: Knowledge<br> Difficulty: Medium<br> Learning Objective: 01-03 <br> Topic: Economic<br>
I want to use preg_replace to remove each of 'Bloom's:...' , 'Difficulty:....', 'Learning Objective:....', 'Topic:...'
I tried to match those terms but it doesn't work.
/Bloom's:.*<br>/ or /Difficulty:.*<br>
Can you show me the right way? Thanks a lot!
Not sure what you want but:
$whole_question = "Bloom's: Knowledge<br> Difficulty: Medium<br> Learning Objective: 01-03 <br> Topic: Economic<br>";
$removeKeys = array(
'Bloom:',
'Difficulty:',
'Learning Objective:',
'Topic:',
);
foreach ($removeKeys as $removeKey){
$removeKey = '/'.$removeKey.'.*<br>/';
$whole_question = preg_replace($removeKey,'<br>',$whole_question);
}
echo $whole_question;//Bloom's: Knowledge<br> <br>

How do I access structured metadata using DocPad?

I'm evaluating DocPad at the moment to see if it will be suitable for our website amongst other things. I'm having trouble working out how to use structured metadata in eco templates. I'm pretty sure it's related to How to display Backbone nested attribute using Eco? but that's unanswered too.
My page looks like:
--- yaml
layout: 'post'
title: "Samuel Johnson's garret - an unexpected lull"
category: 'Digital Publishing'
author:
name: Author Name
page: author
email: author.name#ourdomain.co.uk
---
Unexpected free time, a chilly walk, a brown plaque leads me to
[Dr Johnson's house (http://www.drjohnsonshouse.org/) near Fleet-Street…
and the eco template like:
---
layout: default
---
<article id="post" class="post">
<h1><%= #document.title %></h1>
<h2>By: <%= #document.author.email %></h2>
<div class="post-content"><%- #content %></div>
</article>
The #document.author.email leads to the following error being logged:
TypeError: Cannot read property 'email' of undefined
How do I access that structured metadata?
thanks
Everything seems ok. When I test the same structure, the line <%= #document.author.email %> works. Maybe you have some kind of inconsistency using white spaces and tabs ? You can validate your YAML on this site : http://yamllint.com.
Personally I also use arrays of objects in metadata :
choices:
-
text: "Mercure"
feedback: "Mercure est la planète la plus proche du Soleil, elle se situe à une distance de 0,4 UA"
value: 0
-
text: "Neptune"
feedback: "C'est effectivement la planète la plus éloignée avec une distance de 30 UA."
value: 1
and it works great. Sorry for the text in French but I guess it doesn't really matter for an example.
you can see this example, it works perfectly now, i found my issue and i want to share the solution with you:
---
slides:
-
detailimage: "heliski-img.png"
mainimage: "heliski-g.jpg"
title: "Powder South Heliski Guides"
-
detailimage: "nuevos-vientos-img.png"
mainimage: "nuevos-vientos.jpg"
title: "Centro Experiencial Nuevos Vientos"
---
#full-width-slider.royalSlider.heroSlider.rsMinW
each slide in document.slides
.rsContent
img.rsImg(src='/slideshow/#{slide.mainimage}', alt='#{slide.title}')
.infoBlock.infoBlockLeftBlack.rsABlock(data-fade-effect='', data-move-offset='10', data-move-effect='bottom', data-speed='200')
p #{slide.title}
img.rsImg(src='/slideshow/#{slide.detailimage}', alt='#{slide.title}')
the important thing is the each line, it must say "in document.slides" so i can access from jade the document metadata. :D
the final render will look like this:
<div id="full-width-slider" class="royalSlider heroSlider rsMinW">
<div class="rsContent"><img src="/slideshow/heliski-g.jpg" alt="Powder South Heliski Guides" class="rsImg">
<div data-fade-effect="" data-move-offset="10" data-move-effect="bottom" data-speed="200" class="infoBlock infoBlockLeftBlack rsABlock"></div>
<p>Powder South Heliski Guides</p><img src="/slideshow/heliski-img.png" alt="Powder South Heliski Guides" class="rsImg">
</div>
<div class="rsContent"><img src="/slideshow/nuevos-vientos.jpg" alt="Centro Experiencial Nuevos Vientos" class="rsImg">
<div data-fade-effect="" data-move-offset="10" data-move-effect="bottom" data-speed="200" class="infoBlock infoBlockLeftBlack rsABlock"></div>
<p>Centro Experiencial Nuevos Vientos</p><img src="/slideshow/nuevos-vientos-img.png" alt="Centro Experiencial Nuevos Vientos" class="rsImg">
</div>
</div>