Skip to content

Instantly share code, notes, and snippets.

Created Jun 23, 2020
What would you like to do?
Leaflet map latitude and longitude marker with PHP
if (isset($_GET['lat']) && isset($_GET['lon'])) {
$lat = $_GET['lat'];
$lon = $_GET['lon'];
} else {
echo "<h1>Latitude and Longitude must be set in URL</h1>";
echo "<p>Example: <a href='map.php?lat=-37.818217&lon=144.956784'>map.php?lat=-37.818217&lon=144.956784</a></p>";
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href=""/>
<script src=""></script>
<script src=""></script>
body {
background: rgb(73, 234, 188);
.container {
background-color: white;
width: 25rem;
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
padding: 1.4rem;
box-shadow: 1px 5px 5px 0 rgba(0, 0, 0, 0.20);
border-radius: 0.2rem;
box-sizing: border-box;
.container * {
box-sizing: inherit;
font-size: inherit;
.container #MapBox {
margin-bottom: 0.75rem;
<div class="container">
<div id="MapBox" style="height: 21rem"></div>
$(function () {
setLocation = [<?php echo $lat;?>, <?php echo $lon;?>];
var map ='MapBox').setView(setLocation, 14);
L.tileLayer('https://{s}{z}/{x}/{y}.png', {
attribution: '&copy; <a href="">OpenStreetMap</a> contributors'
var marker = new L.marker(setLocation, {
draggable: false
Copy link

FocaSerghei commented Jun 2, 2022

I have a java script file in which I have some information (the name is xyz.js) how could you search using my function something from that xyz.js and that is map.php? LANDID = XXX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment