I want to send Latitude and longitude values from two TextBoxes to a java script function that displays a marker at that location on the map.
I have written the following code but it doesn't work:
<script type="text/javascript">
var map;
function init()
{
var mapoptions=
{
center: new google.maps.LatLng(17.379064211298, 78.478946685791),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map=new google.maps.Map(document.getElementById("map_can"), mapoptions);
}
function placemark()
{
var ulatlng= new google.maps.LatLng(document.getElementById('<%=TextBox1.ClientID %>'),document.getElementById('<%=TextBox2.ClientID %>'));
var marker = new google.maps.Marker({position:ulatlng,map:map});
}
</script>
Button controls code:
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="placemark()" />
Marker isn't displayed. Also Chrome console doesn't display any errors. Where am I wrong?
data-*attributes, or use class selectors to categorically select elements (you can get theirids dynamically).