how to display a div info under each marker using Mapbox and leaflet - leaflet

I am using mapbow with leaflet to display a map.
I want to add a div under each marker (like belo) but i didn't know how to make it.
I looked almost on all the doc of mapbox markers but I did not find it.
There is maybe a trick to add an HTML element for each marker with a specific information that will be shown when use rlaod
This is a screenshot of what am looking for :
And this is what i have :
Here is my code :
L.mapbox.accessToken = 'pk.MY_TOKEN';
var map = L.mapbox.map('map')
.setView([48, 2.5], 5)
.addLayer(L.mapbox.styleLayer('mapbox://styles/meruem92/cla6ktb2n001v16nw5ludpq67'));
var myLayer = L.mapbox.featureLayer().addTo(map);
let template = `
<h1>Yo sekai !</h1>
<img src="images/disney.jpg" alt="" />
`
var geoJson = {
type: 'FeatureCollection',
features: [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [2.3484063461432183, 48.857478354732855]
},
"properties": {
"tooltip": "totltip 1",
"title": "Paris",
"description": template,
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-3.721208820629982, 40.72384968227116]
},
"properties": {
"tooltip": "totltip 2",
"title": "Mapbox",
"description": "Spain, España",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 3",
"title": "Lincoln Park",
"description": "A northside park that is home to the Lincoln Park Zoo",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.637596, 41.940403],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 4",
"title": "Burnham Park",
"description": "A lakefront park on Chicago's south side",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.603735, 41.829985],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Millennium Park",
"description": "A downtown park known for its art installations and unique architecture",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.622554, 41.882534],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Grant Park",
"description": "A downtown park that is the site of many of Chicago's favorite festivals and events",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.619185, 41.876367],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Humboldt Park",
"description": "A small park on Chicago's northwest side",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.70199, 41.905423],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Douglas Park",
"description": "A small park near in Chicago's North Lawndale neighborhood",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.699329, 41.860092],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Calumet Park",
"description": "A park on the Illinois-Indiana border featuring a historic fieldhouse",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.530221, 41.715515],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Jackson Park",
"description": "A lakeside park that was the site of the 1893 World's Fair",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
}
},
"geometry": {
"coordinates": [-87.580389, 41.783185],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {
"tooltip": "totltip 1",
"title": "Columbus Park",
"description": "A small park in Chicago's Austin neighborhood",
// Store the image url and caption in an array.
'images': [
['https://i.imgur.com/O6QEpBs.jpg','The U.S. Capitol after the burning of Washington during the War of 1812'],
['https://i.imgur.com/xND1MND.jpg','Ford\'s Theatre in the 19th century, site of the 1865 assassination of President Lincoln'],
['https://i.imgur.com/EKJmqui.jpg','The National Cherry Blossom Festival is celebrated around the city each spring.']
],
"icon": {
"iconUrl": "images/marker-figma.svg",
"iconSize": [20, 20],
"iconAnchor": [10, 25],
"popupAnchor": [0, -25],
"className": "dot"
},
"geometry": {
"coordinates": [-87.769775, 41.873683],
"type": "Point"
}
}
]
};
// Add custom popup html to each marker.
myLayer.on('layeradd', function(e) {
var marker = e.layer;
// marker.bindTooltip("my tooltip text").openTooltip();
var feature = marker.feature;
var images = feature.properties.images
var slideshowContent = '';
for(var i = 0; i < images.length; i++) {
var img = images[i];
slideshowContent += '<div class="image' + (i === 0 ? ' active' : '') + '">' +
'<img src="' + img[0] + '" />' +
'<div class="caption">' + img[1] + '</div>' +
'</div>';
}
// Create custom popup content
var popupContent =
'<div id="' + feature.properties.id + '" class="popup">' +
'<h2>' + feature.properties.title + '</h2>' +
'<div class="slideshow">' +
slideshowContent +
'</div>' +
'<div class="cycle">' +
'« Previous' +
'Next »' +
'</div>'
'</div>';
// http://leafletjs.com/reference.html#popup
marker.bindPopup(popupContent,{
minWidth: 320
});
marker.setIcon(L.icon(feature.properties.icon));
for (var i = 0, l = geoJson.features.length; i < l; i++) {
marker.bindTooltip("You clicked marker: " + i).openTooltip();
console.dir(marker._tooltip._content)
}
});
// Add features to the map
myLayer.setGeoJSON(geoJson);
$('#map').on('click', '.popup .cycle a', function() {
var $slideshow = $('.slideshow'),
$newSlide;
if ($(this).hasClass('prev')) {
$newSlide = $slideshow.find('.active').prev();
if ($newSlide.index() < 0) {
$newSlide = $('.image').last();
}
} else {
$newSlide = $slideshow.find('.active').next();
if ($newSlide.index() < 0) {
$newSlide = $('.image').first();
}
}
$slideshow.find('.active').removeClass('active').hide();
$newSlide.addClass('active').show();
return false;
});
body {
background-color: teal;
margin: 0;
}
#map {
height: 100vh;
width: 800px;
margin: auto;
/* margin: 50px auto; */
}
.leaflet-popup-content-wrapper img,
.mapboxgl-popup-content img {
width: 100%;
}
.marker {
background-image: url("images/marker-figma.svg");
background-size: cover;
background-size: contain;
background-repeat: no-repeat;
object-fit: cover;
width: 20px;
height: 20px;
/* border-radius: 50%; */
cursor: pointer;
}
.mapboxgl-popup {
max-width: 200px;
}
.mapboxgl-popup-content {
text-align: center;
font-family: "Open Sans", sans-serif;
}
/* //Popup style */
.popup {
text-align: center;
}
.popup .slideshow .image {
display: none;
}
.popup .slideshow .image.active {
display: block;
}
.popup .slideshow img {
width: 100%;
}
.popup .slideshow .caption {
background: #eee;
padding: 10px;
}
.popup .cycle {
padding: 10px 0 20px;
}
.popup .cycle a.prev {
float: left;
}
.popup .cycle a.next {
float: right;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css">
<!-- <link
rel="stylesheet"
href="https://unpkg.com/leaflet#1.9.2/dist/leaflet.css"
/> -->
<!-- <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v2.9.2/mapbox-gl.css' rel='stylesheet' /> -->
<link href='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css' rel='stylesheet' />
<title>Map project js</title>
</head>
<body>
<div id="map"></div>
<script
src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
crossorigin="anonymous"></script>
<!-- <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v2.9.2/mapbox-gl.js'></script> -->
<!-- <script src="https://unpkg.com/leaflet#1.9.2/dist/leaflet.js"></script> -->
<script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script>
<script src="main2.js"></script>
</body>
</html>

I found it :
for (var i = 0; i < tooltip.length; i++) {
marker.bindTooltip(tooltip).openTooltip();
console.dir(tooltip);
}
i added this loop under marker.setIcon

Related

How to add an 'Offer' for a 'House' (which is not a 'Product' sub-type)?

My idea is put a House definition and then a Product with a Offer. But I do not sell other product, I sell a house.
The Product scheme has a Offer schema inside, but House scheme do not have it. How can I do to put a schema Offer inside my House schema definition?
For now I have this code:
<script type='application/ld+json'>
{
"#context": "http://schema.org/",
"#type": "House",
"numberOfRooms": "4",
"floorSize": {
"#type": "QuantitativeValue",
"unitCode": "metros cuadrados",
"value": "120",
"description": "En Venta piso amplio, exterior, salón, cocina, 4 dormitorios, 1 cuarto de despensa/lavadora, 2 baños (con ventanas), 1 terraza, 5 armarios empotrados, plaza de garaje y 2 rochos (1 bajo cubierta y otro al lado plaza garaje). 120 m2 en planta. 4ª planta "
},
"address": {
"#type": "PostalAddress",
"addressCountry": "España",
"addressLocality": "Burela",
"addressRegion": "A Mariña",
"postalCode": "27880",
"streetAddress": "Lamestra 9",
"description": "A 130 metros de la playa "
},
"geo": [
"-7.360289",
"43.662696"
],
"hasMap": "http://www.softgalia.com/mapapisoburela",
"photos": "http://dechado11.softgalia.com/galerias/index",
"telephone": "677524729"
}
}
</script>
The itemOffered property expects a Product or Service value, but House is neither. And for the other direction: The offers property can’t be specified on House, but on Product, Service, CreativeWork etc.
If you offer to sell a house, this house becomes a product. So you should provide an entity that has two types: House and Product.
{
"#context": "http://schema.org",
"#type": "Offer",
"itemOffered":
{
"#type": ["House", "Product"]
}
}
{
"#context": "http://schema.org",
"#type": ["House", "Product"],
"offers":
{
"#type": "Offer"
}
}
Thanks Jay Gray for your help. This is my code now.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Offer",
"price": "155.000 €",
"priceCurrency": "EUR",
"availableAtOrFrom":
{
"#type": "Place",
"address": {
"#type": "PostalAddress",
"addressCountry": "España",
"addressLocality": "Lugo",
"addressRegion": "Lugo",
"postalCode": "27002",
"streetAddress": "Primavera 40"
},
"telephone": "+34 677524729",
"geo":
{
"#type": "GeoCoordinates",
"latitude": "-7.360232",
"longitude": "43.662330",
"postalCode": "27002"
}
},
"itemOffered":
{
"#type": "House",
"numberOfRooms": "4",
"floorSize": {
"#type": "QuantitativeValue",
"unitCode": "metros cuadrados",
"value": "120",
"description": "En Venta piso amplio, exterior, salón, cocina, 4 dormitorios, 1 cuarto de despensa/lavadora, 2 baños (con ventanas), 1 terraza, 5 armarios empotrados, plaza de garaje y 2 rochos (1 bajo cubierta y otro al lado plaza garaje). 120 m2 en planta. 4ª planta "
},
"amenityFeature": "Al 130 metros de la playa O Cantiño, y en pleno centro de Burela. Supermercado a 150 metros y a 70 metros del parque Rosalía de castro y al mismo tiempo es una zona tranquila. Su situación es inmejorable.",
"address": {
"#type": "PostalAddress",
"addressCountry": "España",
"addressLocality": "Burela",
"addressRegion": "A Mariña",
"postalCode": "27880",
"streetAddress": "Lamestra 9",
"description": "A 130 metros de la playa "
},
"geo": [
"-7.360232",
"43.662330"
],
"hasMap": "https://www.google.es/maps/place/43%C2%B039'44.4%22N+7%C2%B021'36.8%22W/#43.6623443,-7.3690083,3324m/data=!3m2!1e3!4b1!4m8!1m2!2m1!1sR%C3%BAa+da+Lamestra,+Burela!3m4!1s0x0:0x0!8m2!3d43.6623297!4d-7.3602321",
"photos": [ "http://dechado11.softgalia.com/galerias_imagenes/foto-de-la-entrada-vista-hacia-el-despacho",
"http://dechado11.softgalia.com/galerias_imagenes/bano-piso-venta-burela"
],
"telephone": "677524729"
}
}
}

Issue with nested functions eachlayer and onEach feature of leaflet with geoson objects

I am practicing Leaflet to create maps.
In order to find the min value of a set of features I wish to browse the layers of a group layer with the function "eachLayer" then browse the features with the function "onEachFeature".
I think I have a problem with the scope of the variables.
My code is:
<!DOCTYPE html>
<html>
<head>
<title>Layers Control Tutorial - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet#1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<script src="https://unpkg.com/leaflet#1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
<style>
html, body { height: 100%;margin: 0; }
#map { width: 100%; height: 100%;}
</style>
<!-- jQuery - indispensable pour utiliser les fichiers geojson -->
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<!-- Fichier(s) contenant les couches -->
<!-- <script src="troncons.geojson" type="text/javascript"></script> -->
</head>
<body>
<div id='map'></div>
<button id="button1">Station variable1</button>
<button id="button2">Station variable2</button>
<button id="button3">Troncons variable3</button>
<script>
// define the layers groups:
var stationsWait = L.layerGroup();
var GroupLayerTroncons = L.layerGroup();
// Load some stations
var Vincennes = L.circle([48.8473,2.43318], { color: 'red',fillColor: '#f03',fillOpacity: 0.5, radius: 750 }).bindPopup("Choisissez une variable").addTo(stationsWait);
var Nation = L.circle([48.8487,2.39626], { color: 'red',fillColor: '#f03', fillOpacity: 0.5,radius: 750 }).bindPopup("Choisissez une variable").addTo(stationsWait);
// Load some sections of the RERA:
var sections_RERA = {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 1 , "flow": 500 }, "geometry": { "type": "LineString", "coordinates": [ [ 2.22241227492659, 48.897131251501115 ], [ 2.237644924286148, 48.892430179977538 ] ] } },
{ "type": "Feature", "properties": { "id": 2 , "flow": 400 }, "geometry": { "type": "LineString", "coordinates": [ [ 2.237796534409823, 48.892431145089262 ], [ 2.277988160372222, 48.88068267218889 ], [ 2.291233854345376, 48.87646267502052 ], [ 2.295956684874181, 48.874690897366008 ] ] } },
{ "type": "Feature", "properties": { "id": 3 , "flow": 300 }, "geometry": { "type": "LineString", "coordinates": [ [ 2.295958036238904, 48.874590924832241 ], [ 2.308533488711002, 48.874964167617904 ], [ 2.315348461217771, 48.875403260408021 ], [ 2.329165082403959, 48.873581863436044 ], [ 2.330553508046893, 48.871690011018686 ], [ 2.330553508046893, 48.871690011018686 ] ] } },
{ "type": "Feature", "properties": { "id": 4 , "flow": 200}, "geometry": { "type": "LineString", "coordinates": [ [ 2.330554792932899, 48.871590037832199 ], [ 2.34106115320042, 48.867749099632711 ], [ 2.344584312147049, 48.864769023056539 ], [ 2.347801519250009, 48.861987132117697 ] ] } },
{ "type": "Feature", "properties": { "id": 5 , "flow": 100 }, "geometry": { "type": "LineString", "coordinates": [ [ 2.347801519250009, 48.861987132117697 ], [ 2.349954033166742, 48.859499314657278 ], [ 2.357872312519592, 48.856342662783582 ], [ 2.373020720593452, 48.844025242488712 ] ] } },
{ "type": "Feature", "properties": { "id": 6 , "flow": 500}, "geometry": { "type": "LineString", "coordinates": [ [ 2.373020720593452, 48.844025242488712 ], [ 2.375307175290527, 48.842837414357263 ], [ 2.378035989383918, 48.842651667917124 ], [ 2.379696184575886, 48.843160200223871 ], [ 2.384654536154551, 48.846585203162263 ], [ 2.38585340994371, 48.847691165562274 ], [ 2.390073858038943, 48.849512428852194 ], [ 2.397050398888572, 48.848847918381693 ] ] } },
{ "type": "Feature", "properties": { "id": 7, "flow": 250 }, "geometry": { "type": "LineString", "coordinates": [ [ 2.397050398888572, 48.848847918381693 ], [ 2.40254859872989, 48.844976207608681 ], [ 2.417864326491966, 48.843551984219573 ], [ 2.423292942257146, 48.845777878447315 ], [ 2.428427826130349, 48.847202264244189 ], [ 2.434335613031259, 48.847230342470212 ] ] } }
]
}
var sections_others = [{
"type": "Feature",
"properties": {
"id": 12,
"name": "Autres-Autres",
"flow": 500,
"popupContent": "Texte à changer",
"popupContent2": "Text de la nouvelle variable"
},
"geometry": {
"type": "LineString",
"coordinates": [ [2.373068996549787 , 48.844124177694574],[2.373068176412221 , 48.844124882353711]]
}
}
]
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.popupContent) {
layer.bindPopup(feature.properties.popupContent);
}
//console.log ( "The id of the feature is " + feature.properties.id)
}
function style (feature){// paramétrage de la symbologie de la couche "arrondissement"
//return { color: "#046380", weight: 1, fillColor: '#4BB5C1', fillOpacity: .5 };
}
L.geoJson(sections_RERA, { onEachFeature: onEachFeature, style: style }).addTo(GroupLayerTroncons);
sections_RERA.id = 10;
console.log(sections_RERA.id )
// Load sections of an other dummy lines:
function style2 (feature){// paramétrage de la symbologie de la couche "arrondissement"
return { color: "red", weight: 5, fillColor: '#4BB5C1', fillOpacity: .5 };
}
L.geoJson(sections_others, { onEachFeature: onEachFeature, style: style2 }).addTo(GroupLayerTroncons);
sections_others.id = 11;
console.log(sections_others.id )
// Load the map
var mbAttr = 'Map data © OpenStreetMap contributors, ' +
'CC-BY-SA, ' +
'Imagery © Mapbox',
mbUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
var grayscale = L.tileLayer(mbUrl, {id: 'mapbox.light', attribution: mbAttr}),
streets = L.tileLayer(mbUrl, {id: 'mapbox.streets', attribution: mbAttr});
var map = L.map('map', {
center: [48.8666, 2.333],
zoom: 13,
layers: [streets, GroupLayerTroncons, stationsWait]
});
var baseLayers = {"Grayscale": grayscale,"Streets": streets};
var overlays = { "Waiting Times": stationsWait,"Troncons" : GroupLayerTroncons};
L.control.layers(baseLayers, overlays).addTo(map);
//Objectif: Find the min value in a group layer according a given property
function onEachFeature2(feature, layer) {
if (feature.properties && feature.properties.flow) {
console.log ( "The value of the feature property is " + feature.properties.flow); // later we use the OneProperty variable
}
}
// Body of the GetMin function
function GetMin(GroupLayer, OneProperty){
GroupLayer.eachLayer(function (OneLayer) {
L.geoJson(OneLayer, { // it's work whith sections_RERA instead of OneLayer
onEachFeature: onEachFeature2
// onEachFeature : function onEachFeature3 (feature, layer) { console.log( feature.properties.flow); layer.bindPopup("feature.properties.flow"); }
})
console.log ( "theoretically we change layer----");
})};
// Call of the function
var OneProperty = "Flow";
GetMin(GroupLayerTroncons, OneProperty);
</script>
</body>
</html>
The web console return:
Error: Invalid GeoJSON object.
But, it works when I replace the local variable "OneLayer" by the global variables "sections_RERA" or "sections_others". (line 135)
"OneLayer" and "sections_RERA", is it the same type of object?
Leaflet's L.geoJSON factory takes a raw GeoJSON data object (like your sections_RERA variable) as first parameter, not a Leaflet already built layer (like the child layers of your GroupLayerTroncons variable that are looped through in your GetMin function).
It is unclear what you are trying to achieve. If you just want to read the original GeoJSON data from your layers, do so directly in your eachLayer callback. The properties are available on each layer as layer.feature.properties:
var groupLayer = L.layerGroup();
// Nesting a Leaflet GeoJSON Layer Group into groupLayer Layer Group.
var geoJsonGroupLayer = L.geoJSON(geoJsonRawData, options).addTo(groupLayer);
groupLayer.eachLayer(inspectLayer);
function inspectLayer(layer) {
if (layer.feature && layer.feature.properties) {
// layer is a non-group, built from GeoJSON data.
// inspect the layer...
} else if (layer instanceof L.LayerGroup) {
// layer is a nested Layer Group.
// Recursive call to inspectLayer function.
layer.eachLayer(inspectLayer);
}
}

How can show the mapboxgl round marker with different colors based on the no of occurrences on the particular lat and long?

I want to show a colored (for ex: red) round marker in Mapboxgl. Suppose if I have multiple occurrences of the same latitude and longitude then color should be changed to blue(for ex) and its count.
Consider there is only once occurrence of a LatLong then I need to show a red colored round marker. If there are 3 occurrences then I need to show blue colored round marker with 3.
Tried the following code,
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<style>
.mapboxgl-popup {
max-width: 400px;
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
</style>
<div id='map'></div>
<script>
mapboxgl.accessToken = 'my access token';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [-77.04, 38.907],
zoom: 11.15
});
map.on('load', function () {
// Add a layer showing the places.
map.addLayer({
"id": "places",
"type": "symbol",
"source": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"description": "<strong>Make it Mount Pleasant</strong><p>Make it Mount Pleasant is a handmade and vintage market and afternoon of live entertainment and kids activities. 12:00-6:00 p.m.</p>",
"icon": "theatre"
},
"geometry": {
"type": "Point",
"coordinates": [-77.038659, 38.931567]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Mad Men Season Five Finale Watch Party</strong><p>Head to Lounge 201 (201 Massachusetts Avenue NE) Sunday for a Mad Men Season Five Finale Watch Party, complete with 60s costume contest, Mad Men trivia, and retro food and drink. 8:00-11:00 p.m. $10 general admission, $20 admission and two hour open bar.</p>",
"icon": "theatre"
},
"geometry": {
"type": "Point",
"coordinates": [-77.003168, 38.894651]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Big Backyard Beach Bash and Wine Fest</strong><p>EatBar (2761 Washington Boulevard Arlington VA) is throwing a Big Backyard Beach Bash and Wine Fest on Saturday, serving up conch fritters, fish tacos and crab sliders, and Red Apron hot dogs. 12:00-3:00 p.m. $25.grill hot dogs.</p>",
"icon": "bar"
},
"geometry": {
"type": "Point",
"coordinates": [-77.090372, 38.881189]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Ballston Arts & Crafts Market</strong><p>The Ballston Arts & Crafts Market sets up shop next to the Ballston metro this Saturday for the first of five dates this summer. Nearly 35 artists and crafters will be on hand selling their wares. 10:00-4:00 p.m.</p>",
"icon": "art-gallery"
},
"geometry": {
"type": "Point",
"coordinates": [-77.111561, 38.882342]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Seersucker Bike Ride and Social</strong><p>Feeling dandy? Get fancy, grab your bike, and take part in this year's Seersucker Social bike ride from Dandies and Quaintrelles. After the ride enjoy a lawn party at Hillwood with jazz, cocktails, paper hat-making, and more. 11:00-7:00 p.m.</p>",
"icon": "bicycle"
},
"geometry": {
"type": "Point",
"coordinates": [-77.052477, 38.943951]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Capital Pride Parade</strong><p>The annual Capital Pride Parade makes its way through Dupont this Saturday. 4:30 p.m. Free.</p>",
"icon": "star"
},
"geometry": {
"type": "Point",
"coordinates": [-77.043444, 38.909664]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Muhsinah</strong><p>Jazz-influenced hip hop artist Muhsinah plays the Black Cat (1811 14th Street NW) tonight with Exit Clov and Gods’illa. 9:00 p.m. $12.</p>",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.031706, 38.914581]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>A Little Night Music</strong><p>The Arlington Players' production of Stephen Sondheim's <em>A Little Night Music</em> comes to the Kogod Cradle at The Mead Center for American Theater (1101 6th Street SW) this weekend and next. 8:00 p.m.</p>",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.020945, 38.878241]
}
}, {
"type": "Feature",
"properties": {
"description": "<strong>Truckeroo</strong><p>Truckeroo brings dozens of food trucks, live music, and games to half and M Street SE (across from Navy Yard Metro Station) today from 11:00 a.m. to 11:00 p.m.</p>",
"icon": "music"
},
"geometry": {
"type": "Point",
"coordinates": [-77.007481, 38.876516]
}
}]
}
},
"layout": {
"icon-image": "{icon}-15",
"icon-allow-overlap": true
}
});
// When a click event occurs on a feature in the places layer, open a popup at the
// location of the feature, with description HTML from its properties.
map.on('click', 'places', function (e) {
new mapboxgl.Popup()
.setLngLat(e.features[0].geometry.coordinates)
.setHTML(e.features[0].properties.description)
.addTo(map);
});
// Change the cursor to a pointer when the mouse is over the places layer.
map.on('mouseenter', 'places', function () {
map.getCanvas().style.cursor = 'pointer';
});
// Change it back to a pointer when it leaves.
map.on('mouseleave', 'places', function () {
map.getCanvas().style.cursor = '';
});
});
</script>
</body>

how to code sap.m.sample.ListGrouping by using js view in openui5

hi i need List grouping control by using js view.but openui5 provides code by using xml view.
https://openui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.ListGrouping/preview
how to convert this code into js view and how to make ListGrouping able to selection for both element level and group level and change this as dropdown box
List.view.xml
<mvc:View
controllerName="sap.m.sample.ListGrouping.List"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<List
items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}"
headerText="Products" >
<StandardListItem
title="{Name}"
description="{ProductId}"
icon="{ProductPicUrl}"
iconDensityAware="false"
iconInset="false" />
</List>
</mvc:View>
List.controller.js
sap.ui.define([
'jquery.sap.global',
'sap/m/GroupHeaderListItem',
'sap/ui/core/mvc/Controller',
'sap/ui/model/json/JSONModel'
], function(jQuery, GroupHeaderListItem, Controller, JSONModel) {
"use strict";
var ListController = Controller.extend("sap.m.sample.ListGrouping.List", {
onInit : function (evt) {
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
this.getView().setModel(oModel);
},
getGroupHeader: function (oGroup){
return new GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
} );
}
});
return ListController;
});
how to write the same code by using js view
I have tried like as follows, but i am getting Error: Missing template or factory function for aggregation items of Element sap.m.List#__list0 !
List.view.js
sap.ui.jsview("oui5mvc.List", {
getControllerName : function() {
return "oui5mvc.List";
},
createContent : function(oController) {
odbbshiftGlobalId = this.getId();
var oMyFlexbox = new sap.m.FlexBox({
items: [
oList = new sap.m.List({
width: '500px',
group: true,
groupHeaderFactory: '.getGroupHeader',
items: [
]
}),
]
});
oMyFlexbox.placeAt(this.getId()).addStyleClass("tes");
}
});
List.controller.js
sap.ui.controller("oui5mvc.List", {
onInit: function() {
var data = {
"ProductCollection": [
{
"ProductId": "1239102",
"Name": "Power Projector 4713",
"Category": "Projector",
"SupplierName": "Titanium",
"Description": "A very powerful projector with special features for Internet usability, USB",
"WeightMeasure": 1467,
"WeightUnit": "g",
"Price": 856.49,
"CurrencyCode": "EUR",
"Status": "Available",
"Quantity": 3,
"UoM": "PC",
"Width": 51,
"Depth": 42,
"Height": 18,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-6100.jpg"
},
{
"ProductId": "2212-121-828",
"Name": "Gladiator MX",
"Category": "Graphics Card",
"SupplierName": "Technocom",
"Description": "Gladiator MX: DDR2 RoHS 128MB Supporting 512MB Clock rate: 350 MHz Memory Clock: 533 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 32-bit Highlighted Features: DVI Out, TV Out , HDTV",
"WeightMeasure": 321,
"WeightUnit": "g",
"Price": 81.7,
"CurrencyCode": "EUR",
"Status": "Discontinued",
"Quantity": 10,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1071.jpg"
},
{
"ProductId": "K47322.1",
"Name": "Hurricane GX",
"Category": "Graphics Card",
"SupplierName": "Red Point Stores",
"Description": "Hurricane GX: DDR2 RoHS 512MB Supporting 1024MB Clock rate: 550 MHz Memory Clock: 933 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 64-bit Highlighted Features: DVI Out, TV-In, TV-Out, HDTV",
"WeightMeasure": 588,
"WeightUnit": "g",
"Price": 219,
"CurrencyCode": "EUR",
"Status": "Out of Stock",
"Quantity": 25,
"UoM": "PC",
"Width": 34,
"Depth": 14,
"Height": 2,
"DimUnit": "cm",
"ProductPicUrl": "https://openui5.hana.ondemand.com/test-resources/sap/ui/demokit/explored/img/HT-1072.jpg"
},
],
"ProductCollectionStats": {
"Counts": {
"Total": 14,
"Weight": {
"Ok": 7,
"Heavy": 5,
"Overweight": 2
}
},
"Groups": {
"Category": {
"Projector": 1,
"Graphics Card": 2,
"Accessory": 4,
"Printer": 2,
"Monitor": 3,
"Laptop": 1,
"Keyboard": 1
},
"SupplierName": {
"Titanium": 3,
"Technocom": 3,
"Red Point Stores": 5,
"Very Best Screens": 3
}
},
"Filters": [
{
"type": "Category",
"values": [
{
"text": "Projector",
"data": 1
},
{
"text": "Graphics Card",
"data": 2
},
{
"text": "Accessory",
"data": 4
},
{
"text": "Printer",
"data": 2
},
{
"text": "Monitor",
"data": 3
},
{
"text": "Laptop",
"data": 1
},
{
"text": "Keyboard",
"data": 1
}
]
},
{
"type": "SupplierName",
"values": [
{
"text": "Titanium",
"data": 3
},
{
"text": "Technocom",
"data": 3
},
{
"text": "Red Point Stores",
"data": 5
},
{
"text": "Very Best Screens",
"data": 3
}
]
}
]
}
};
var oTemplate11 = new sap.m.StandardListItem({title : "{Name}"});
oList.setModel(new sap.ui.model.json.JSONModel(data));
oList.bindItems("/ProductCollection");
oList.placeAt('content');
},
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
});
},
});
Your call to bind items to the list is not entirely correct.
The method takes an object with binding information as parameter instead of just the path to the model property. See the documentation for bindItems and bindAggregation in general.
In your case it should look like
oList.bindItems({
path: "/ProductCollection",
template: new sap.m.StandardListItem({
title: "{Name}",
description: "{ProductId}",
icon: "{ProductPicUrl}"
})
});

How can I get the URL of a Facebook video?

I want to embed a Facebook video in a website I'm making. The video is on a company page. I'm making the website for the same company, so don't worry about copyrights. In chrome dev tools I found a link ending with .swf, but when I paste it in my address bar, nothing loads.
This is the link that I found:
https://fbstatic-a.akamaihd.net/rsrc.php/v1/yA/r/7HOXOhotVs4.swf
and it's within
<embed type="application/x-shockwave-flash" src="https://fbstatic-a.akamaihd.net/rsrc.php/v1/yA/r/7HOXOhotVs4.swf" width="745" height="600" style="display: block;" id="swf_id_556c3725cac3b0881505628" name="swf_id_556c3725cac3b0881505628" bgcolor="#000000" quality="high" allowfullscreen="true" allowscriptaccess="always" salign="tl" scale="noscale" wmode="opaque" flashvars="params=%7B%22auto_hd%22%3Afalse%2C%22autoplay_reason%22%3A%22unknown%22%2C%22default_hd%22%3Afalse%2C%22disable_native_controls%22%3Afalse%2C%22inline_player%22%3Afalse%2C%22pixel_ratio%22%3A1%2C%22preload%22%3Afalse%2C%22start_muted%22%3Afalse%2C%22video_data%22%3A%5B%7B%22hd_src%22%3A%22https%3A%5C%2F%5C%2Ffbcdn-video-p-a.akamaihd.net%5C%2Fhvideo-ak-xap1%5C%2Fv%5C%2Ft43.1792-2%5C%2F1326123_10151866439299059_44825_n.mp4%3Fefg%3DeyJybHIiOjE1MDAsInJsYSI6MTY0MH0%5Cu00253D%26rl%3D1500%26vabr%3D853%26oh%3D74581c7ec1aed810cee512cf605f59a6%26oe%3D556C6506%26__gda__%3D1433162747_d02fa4f48cca138eefa857ab4143ffcd%22%2C%22is_hds%22%3Afalse%2C%22is_hls%22%3Afalse%2C%22player_type%22%3A%22progressive%22%2C%22rotation%22%3A0%2C%22sd_src%22%3A%22https%3A%5C%2F%5C%2Fvideo-fra3-1.xx.fbcdn.net%5C%2Fhvideo-xfp1%5C%2Fv%5C%2Ft42.1790-2%5C%2F1088689_10151793358514059_13394_n.mp4%3Fefg%3DeyJybHIiOjcwMiwicmxhIjo3NTB9%26rl%3D702%26vabr%3D390%26oh%3D7ee558badea9b238dafca2ef58e7edc2%26oe%3D556C5338%22%2C%22video_id%22%3A%2210150099114814059%22%2C%22sd_tag%22%3A%22legacy_sd%22%2C%22hd_tag%22%3A%22legacy_hd%22%2C%22sd_src_no_ratelimit%22%3A%22https%3A%5C%2F%5C%2Fvideo-fra3-1.xx.fbcdn.net%5C%2Fhvideo-xfp1%5C%2Fv%5C%2Ft42.1790-2%5C%2F1088689_10151793358514059_13394_n.mp4%3Foh%3D7ee558badea9b238dafca2ef58e7edc2%26oe%3D556C5338%22%2C%22hd_src_no_ratelimit%22%3A%22https%3A%5C%2F%5C%2Ffbcdn-video-p-a.akamaihd.net%5C%2Fhvideo-ak-xap1%5C%2Fv%5C%2Ft43.1792-2%5C%2F1326123_10151866439299059_44825_n.mp4%3Foh%3D74581c7ec1aed810cee512cf605f59a6%26oe%3D556C6506%26__gda__%3D1433162747_f63ef4927642e728c87578d0a8f20b24%22%2C%22subtitles_src%22%3Anull%7D%5D%2C%22show_captions_default%22%3Afalse%2C%22persistent_volume%22%3Atrue%2C%22buffer_length%22%3A0.1%7D&width=720&height=576&user=1485939356&log=no&div_id=id_556c3725cac3b0881505628&swf_id=swf_id_556c3725cac3b0881505628&browser=Chrome+43.0.2357.81&tracking_domain=https%3A%2F%2Fpixel.facebook.com&post_form_id=&string_table=https%3A%2F%2Fs-static.ak.facebook.com%2Fflash_strings.php%2Ft99524%2Fen_US">
If you have a Page either by page_id or page name, you can request the Page's videos by issueing the following call:
/?id={page_name_or_id}&fields=videos{embed_html,format}
For example
/?id=arcadefire&fields=videos{embed_html,format}
returns
{
"videos": {
"data": [
{
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id=10152504597050225\" width=\"1280\" height=\"720\" frameborder=\"0\"></iframe>",
"format": [
{
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id=10152504597050225\" width=\"130\" height=\"73\" frameborder=\"0\"></iframe>",
"filter": "130x130",
"height": 73,
"picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/s130x130/10442736_10152504602350225_10152504597050225_50690_845_b.jpg?oh=fbb990289488a174dccb11ea707d4e9e&oe=55EC60DE&__gda__=1443431681_74940fd5711f2f749a42eef6e8de4850",
"width": 130
},
{
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id=10152504597050225\" width=\"480\" height=\"270\" frameborder=\"0\"></iframe>",
"filter": "480x480",
"height": 270,
"picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/s480x480/10442736_10152504602350225_10152504597050225_50690_845_b.jpg?oh=460bc8e4c46241fbc3166da05105cec1&oe=560C729F&__gda__=1442097728_96f303b1a4f674a80af8141ae2a37c10",
"width": 480
},
{
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id=10152504597050225\" width=\"720\" height=\"405\" frameborder=\"0\"></iframe>",
"filter": "720x720",
"height": 405,
"picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/s720x720/10442736_10152504602350225_10152504597050225_50690_845_b.jpg?oh=7688991f560c76473752743c73847e95&oe=55FF622B&__gda__=1442167796_6f588e161caed3d5fefdebd3b0f78157",
"width": 720
},
{
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id=10152504597050225\" width=\"1280\" height=\"720\" frameborder=\"0\"></iframe>",
"filter": "native",
"height": 720,
"picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/10442736_10152504602350225_10152504597050225_50690_845_b.jpg?oh=863e992c8cb4b1dccbc63c5140e0b166&oe=560A85CD&__gda__=1441785373_4469686cb72f1573c8ef64c17ecfdd5a",
"width": 1280
}
],
"updated_time": "2015-03-05T02:15:51+0000",
"id": "10152504597050225"
}
],
"paging": {
"cursors": {
"before": "MTAxNTI1MDQ1OTcwNTAyMjU=",
"after": "MTAxNTI1MDQ1OTcwNTAyMjU="
},
"next": "https://graph.facebook.com/v2.3/152513780224/videos?pretty=0&fields=embed_html,format&limit=1&after=MTAxNTI1MDQ1OTcwNTAyMjU="
}
},
"id": "152513780224"
}
See
https://developers.facebook.com/docs/graph-api/reference/video