I am creating a google map in order to display store locations of a brand across india…
i have stored the complete address, with latitude & longitude in my SQL server database…
here I am able to get the address from database and display in my web page, but i am stuck with, mapping the address on google map…
here i have kept a text box so that the user enters his state/city/any location name, and clicks search button, then i have to mark the corresponding store location on the map by a marker..
here’s my code for googgle map…
<script type="text/javascript">
var infowindow = null;
function initialize() {
//var centerMap = new google.maps.LatLng(13.040547,80.230805);
var centerMap = new google.maps.LatLng(12.264864, 77.937012);
var myOptions = {
zoom: 7,
center: centerMap,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
setMarkers(map, sites);
infowindow = new google.maps.InfoWindow({ });
}
//var sites = '<%=TextBox1.Text%>'
//alert(sites);
//[
//// ['Ambattur', 13.119438,80.148182, 4, 'Ambattur, Chennai, Tamil Nadu, India, 600031'],['Avadi', 13.124453,80.101662, 1, 'Avadi, Tamil Nadu, India, 600017'], ['Jayanagar', 12.928945,77.590599, 1, 'Jayanagar, Bangalore, Karnataka, India, 560041'],['Indira Nagar', 12.973697,77.641325, 1, 'Indira Nagar, Bangalore, Karnataka, India, 560038'],['TamilNadu', 11.415418,78.662109, 1, 'TamilNadu, India, 600017']
//];
function setMarkers(map, markers) {
for (var i = 0; i < markers.length; i++) {
var sites = markers[i];
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
icon: new google.maps.MarkerImage(
'Images/R.png ',
null, null, new google.maps.Point(0, 42)),
title: sites[0],
zIndex: sites[3],
html: sites[4]
});
google.maps.event.addListener(marker, "click", function () {
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
}
</script>
here, i have sites variable, so that i can map my locations on a map,
but here i need to map them from database…
any help will be appreciated…
thanks
shameer ali shaik
Guruparan Giritharan..
As i have told in my question, I want to locate stores across india.. & the sore details will be stored in database..
Now, i am able to get the store details & mark their location on map by your code..
earlier it is working fine for pincode, in the sense if you provide pincode in your searchbox, it will retrieve the corresponding
store details..
Now, as per my code, in my reply for your blog post, i am able to enter only string values in the textbox., here i need to implement it for numeric values(pincode) also,
here’s my code of update panel and timer click event..
here in the select statement, i need for pincode also..
any help will be thankful..