Rocky Rocky

Rocky Rocky

  • NA
  • 317
  • 152.2k

How to set constant position in google map in c#

Feb 5 2014 7:25 AM
Hi Friends,


i wanna make one application with google map enable spots with zoom function


so i searched on google & find some codes for making dots and zoom but i doesn't get the code for constant show(i.e when i run my code ll show only tamilnadu region i can zoom in tamil nadu.... when i zoom out its default shows tamil nadu map only )

how to make a code?


my codes for google map and zoom

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Googletag.aspx.cs" Inherits="Googletag" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Jquery Google Spots With Zoom</title>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var markers = [

{
"title": "G K Traders",
"lat": 10.909113,
"lng": 78.699475,
"description": "Manachanallur"
},
{
"title": "Vedham Enterprises",
"lat": 10.961695,
"lng": 78.67927,
"description": "Kumbakonam"
},
{
"title": "Sri Anandha Agencies",
"lat": 10.805891,
"lng": 78.67927,
"description": "Trichy"
},
{
"title": "Murugappa Electricals",
"lat": 10.379663,
"lng": 78.820845,
"description": "Pudhukottai"
},

{
"title": "New Century Traders",
"lat": 10.609268,
"lng": 78.422689,
"description": "Manaparai"
}];
var mapOptions = {
center: new google.maps.LatLng(11.44, 78.79),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
// marker:true

};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});

(function(marker, data) {

// Attaching a click event to the current marker
//google.maps.event.addListener(marker, "click", function(e) {
//infoWindow.setContent(data.description);
//infoWindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function(event) {
map.panTo(marker.getPosition()); //zoom the position of geo location
// infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
</script>
</head>
<body onload="initialize()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 1000px; height: 600px"></div>
</form>
</body>
</html>

Answers (1)