User Defined Map

After a long time, finally I am  here for you to write a blog. It doesn’t mean that I was not working but due to academics work.

Huhh.. Now come to OSM again.

It’s very difficult for me to mouse the map to a particular loaction everytime while loading the map.

So, what I want is to enter the latitude and longitude of my own choice and browser should render that location while loading.

Now, we will try to do the same.

Just add two files name “input.html” and “process.php”. I added both files in the same directory that of the “slippymap.html”.

Content of both files are shown below.


<h4>SPT Test: Site location</h4>
<form action=”process.php” method=”post”>
<select name=”zoom” id=”zoom”>
Latitude: <input name=”lat” type=”text” id=”lat”/>
Longitude: <input name=”lon” type=”text” id=”lon”/>
<button type=”submit” onclick=”qwer()” >submit</button>

function qwer(){
a = document.getElementById(“lat”).value;
b = document.getElementById(“lon”).value;
c = document.getElementById(“zoom”).value;

sessionStorage.setItem(“lat”, a);
sessionStorage.setItem(“lon”, b);




You ordered zoom <?php echo $_POST[“zoom”] ; ?>  at lat <?php echo $_POST[“lat”] ; ?>  and long <?php echo $_POST[“lon”] ; ?> <br />TCC<a href=””>Get location of site on Map</a>



In “slippymap.html”  file just make the following changes.



<script type=”text/javascript”>
var lat=sessionStorage.getItem(“lat”);
var lon=sessionStorage.getItem(“lon”);
var zoom=sessionStorage.getItem(“zoom”);
var map;


Now, open the file input.html in the browser and proceed further as shown.



You will be able to see the map at the desired location.


Have a nice day.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s