<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<p>User can take his position on map for another input and find this again for another user</p>
<div id="map_canvas"></div>
function initialize() {
var myMapOptions = {
zoom: 17,
center: new google.maps.LatLng(23.75861566043553, 90.38536486649514),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'), myMapOptions);
// Create a div to hold everything else
var controlDiv = document.createElement('DIV');
controlDiv.id = "controls";
// Create an input field
var controlInput = document.createElement('input');
controlInput.id = "some-information";
controlInput.name = "some-information";
controlInput.value = "Hi there!";
// Create a label
var controlLabel = document.createElement('label');
controlLabel.innerHTML = 'Some information';
controlLabel.setAttribute("for","some-information");
// Create a button to send the information
var controlButton = document.createElement('a');
controlButton.innerHTML = 'Send it!';
// Append everything to the wrapper div
controlDiv.appendChild(controlLabel);
controlDiv.appendChild(controlInput);
controlDiv.appendChild(controlButton);
var onClick = function() {
var inputvalue = $("#some-information").val();
alert("You entered: '" + inputvalue + "', map center is at " + map.getCenter());
};
google.maps.event.addDomListener(controlButton, 'click', onClick);
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(controlDiv);
}
jQuery(document).ready(initialize);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.