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

does not appear #10

Open
aero77 opened this issue Apr 23, 2020 · 1 comment
Open

does not appear #10

aero77 opened this issue Apr 23, 2020 · 1 comment

Comments

@aero77
Copy link

aero77 commented Apr 23, 2020

I get the map visible and everything but not the photolayer and any of the pics, Can anyone help me see what I'm doing wrong?

` <script>

var mbAttr = 'Map data © OpenStreetMap contributors, ' +
'CC-BY-SA, ' +
'Imagery © Mapbox',
mbUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=xxxxxxxxxxxxxxxxxx';

var grayscale = L.tileLayer(mbUrl, {id: 'mapbox/light-v9', tileSize: 512, zoomOffset: -1, attribution: mbAttr}),
streets = L.tileLayer(mbUrl, {id: 'mapbox/streets-v11', tileSize: 512, zoomOffset: -1, attribution: mbAttr});

var map = L.map('map', {
fullscreenControl: true,
center: [39.7518606,-84.1879965],
zoom: 11,
layers: [streets]
});

var hash = L.hash(map);

var baseLayers = {
"Grayscale": grayscale,
"Streets": streets
};

L.control.layers(baseLayers).addTo(map);

reqwest({
url: 'results.json',
type: 'json',
success: function (data) {
var photos = [];
var url = '../uploads/userUpload/';
for (var i = 0; i < data.length; i++) {
var photo = data[i];
photos.push({
lat: data[i].lat,
lng: data[i].lon,
url: url + data[i].picture,
caption: data[i].title,
thumbnail: url + data[i].thumbnail
});
}
photoLayer.add(photos).addTo(map);
}
});

var photoLayer = L.photo.cluster().on('click', function (evt) {
	var photo = evt.layer.photo,
		template = '<img src="{url}"/></a><p>{caption}</p>';

	if (photo.video && (!!document.createElement('video').canPlayType('video/mp4; codecs=avc1.42E01E,mp4a.40.2'))) {
		template = '<video autoplay controls poster="{url}"><source src="{video}" type="video/mp4"/></video>';
	}; 

	evt.layer.bindPopup(L.Util.template(template, photo), {
		className: 'leaflet-popup-photo',
		minWidth: 400
	}).openPopup();
});

</script>`

@aero77
Copy link
Author

aero77 commented Apr 23, 2020

This is how my JSON looks

No Title??? ===> Array
(
[photos] => Array
(
[0] => Array
(
[title] => 2019-07-27 21:12:23
[url] => https://www.dfdsfdsfd.dfd/photos/userUpload/
[thumbnail] => thumb_20190727_211223.jpg
[picture] => 20190727_211223.jpg
[coordinates] => 39.764262277778, -84.189678194444
[lat] => 39.764262277778
[lon] => -84.189678194444
)

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

1 participant