Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
hello,

how to set satellite view by default instead of map view in google map in asp.net application.

I post my coding which works correctly. But it shows map view by default. so, how to set satellite view by default instead of map view in google map?

aspx :

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<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?&sensor=false">
</script>

<script type="text/javascript">
function initialize() {
var longu = document.getElementById('<%=hdnlatlon.ClientID %>').value;

var longi = document.getElementById('<%=hdnlog.ClientID %>').value;

var myLatlng = new google.maps.LatLng(longu,longi);

// This is used to center the map to show our markers


var mapOptions = {
center: myLatlng,
zoom: 25,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
<asp:HiddenField ID="hdnlatlon" runat="server"/>
<asp:HiddenField ID="hdnlog" runat="server"/>
<div id="map_canvas" style="width: 900px; height: 450px"></div>

</asp:Content>

aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.XPath;
using System.Data;
using System.Data.SqlClient;

namespace googlelatandlong
{
public partial class _Default : System.Web.UI.Page
{
string address;
string sensor;

protected void Page_Load(object sender, EventArgs e)
{
GetLongitudeAndLatitude(address, sensor) ;
//hdnlatlon.Value = s;

}
public void GetLongitudeAndLatitude(string address, string sensor)
{
string urlAddress = "http://maps.googleapis.com/maps/api/geocode/xml?address=Nelson Manickam Rd, Aminjikarai, Chennai, TN,&sensor=false";
// string returnValue= "";
string r;
string s;
//string returnValue1= "";
try
{
XmlDocument objXmlDocument = new XmlDocument();
objXmlDocument.Load(urlAddress);
XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/GeocodeResponse/result/geometry/location");
foreach (XmlNode objXmlNode in objXmlNodeList)
{
// GET LONGITUDE
r = objXmlNode.ChildNodes.Item(0).InnerText;
hdnlatlon.Value = r;
// GET LATITUDE
//returnValue += "," + objXmlNode.ChildNodes.Item(1).InnerText;
s = objXmlNode.ChildNodes.Item(1).InnerText;
hdnlog.Value = s;
// Session["latlon"] = returnValue;

}


}


catch

{

}


}
}
}
Posted

1 solution

I chaged from mapTypeId: google.maps.MapTypeId.ROADMAP into mapTypeId: google.maps.MapTypeId.SATELLITE. now it shows by default satellite view. Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900