Using this way we
can make the Polygon on Google Map, but you have to pass the geofence
array of Latitude and longitude. you can pass this array from asp.net
using ClientScript.RegisterArrayDeclaration method and pass the LatLng
string in below format
ClientScript.RegisterArrayDeclaration("geo", "'38.97441,-77.013798','38.972257,-77.011043','38.97011,-77.008298','38.96966,-77.007743',");
The output of this array will be like
<scri pt type="text/ javascript">
//<![CDATA[
var geo = new Array('38.97441,-77.013798','38.972257,-77.011043','38.97011,-77.008298');
//]]>
</sc ript>
function initialize() {
var myLatlng = new google.maps.LatLng(latitude[0], longitude[0]);
var myOptions = {
zoom: parseInt(zoomsize[0]),
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var polys = [];
var labels = [];
var pts = [];
var pts1 = [];
var polys1 = [];
for (var i = 0; i < geo.length; i++) {
var arg = geo[i].split(",");
pts[i] = new google.maps.LatLng(parseFloat(arg[0]),
parseFloat(arg[1]));
}
var myTrip = pts;
var flightPath = new google.maps.Polygon({
path: myTrip,
strokeColor: "#FF0000",
strokeOpacity: 1,
strokeWeight: 1,
fillColor: "#ffffff",
fillOpacity: 0
});
flightPath.setMap(map);
}
ClientScript.RegisterArrayDeclaration("geo", "'38.97441,-77.013798','38.972257,-77.011043','38.97011,-77.008298','38.96966,-77.007743',");
The output of this array will be like
<scri pt type="text/ javascript">
//<![CDATA[
var geo = new Array('38.97441,-77.013798','38.972257,-77.011043','38.97011,-77.008298');
//]]>
</sc ript>
function initialize() {
var myLatlng = new google.maps.LatLng(latitude[0], longitude[0]);
var myOptions = {
zoom: parseInt(zoomsize[0]),
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var polys = [];
var labels = [];
var pts = [];
var pts1 = [];
var polys1 = [];
for (var i = 0; i < geo.length; i++) {
var arg = geo[i].split(",");
pts[i] = new google.maps.LatLng(parseFloat(arg[0]),
parseFloat(arg[1]));
}
var myTrip = pts;
var flightPath = new google.maps.Polygon({
path: myTrip,
strokeColor: "#FF0000",
strokeOpacity: 1,
strokeWeight: 1,
fillColor: "#ffffff",
fillOpacity: 0
});
flightPath.setMap(map);
}