Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function initialize() {
- var map = L.map('map', {
- crs: L.CRS.Simple,
- minZoom: -5
- });
- var bounds = [[-100,-100], [100,100]];
- var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
- //retourne les coordonées pour X,Y
- var yx = L.latLng;
- var xy = function(x, y) {
- if (L.Util.isArray(x)) { // When doing xy([x, y]);
- return yx(x[1], x[0]);
- }
- return yx(y, x); // When doing xy(x, y);
- };
- //entrée des données
- var centre = L.icon({
- iconUrl: 'marker-icon.png',
- iconSize: [20, 30],
- });
- var milieu = xy( 0, 0);
- L.marker( milieu, {icon: centre}).addTo(map).bindPopup( 'Centre du monde');
- //debut d'insertion de champi
- let creatures = JSON.parse('<?php echo $jsonC ?>' )
- for (creature of creatures) {
- console.log("id:", creature.id, creature._x, creature._y, creature._owner)
- }
- let plantes = JSON.parse('<?php echo $jsonP ?>' )
- for (plante of plantes) {
- console.log("id:", plante.id, plante._x, plante._y)
- }
- var c = 0;
- NbElems = Object.keys(creatures).length;
- while (c != NbElems) {
- var logo = L.icon({
- iconUrl: 'creature.png',
- iconSize: [10, 10],
- });
- var id = xy( creatures[c]._x, creatures[c]._y);
- L.marker( id, {icon: logo}).addTo(map).bindPopup( ' ' + creatures[c]._owner + ' ' );
- c++;
- }
- var p = 0;
- NbElems = Object.keys(plantes).length;
- while (p != NbElems) {
- var logo = L.icon({
- iconUrl: 'plante.png',
- iconSize: [10, 10],
- });
- var id = xy( plantes[p]._x, plantes[p]._y);
- L.marker( id, {icon: logo}).addTo(map).bindPopup( ' ' + plantes[p].id + ' ' );
- p++;
- }
- map.fitBounds(bounds);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement