<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Mobile.Master" CodeBehind="MyMap.aspx.vb" Inherits="WebApplication1.MyMap" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=My_Code_Here&sensor=false">
</script>
<body onload="initialize()">
<div id="mapArea" style="width: 500px; height: 500px;">
</div>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</body>
</html>
</asp:Content>
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class MapAvailableTerritories
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim markers As String = ""
markers = GetMarkers()
Literal1.Text = "<script type='text/javascript'>" +
"function initialize() {" +
"var mapOptions = {" +
"center: new google.maps.LatLng(35.372278, -80.633568)," +
"zoom: 9," +
"mapTypeId : google.maps.MapTypeId.ROADMAP" +
"};" +
"var myMap = new google.maps.Map(document.getElementById('mapArea'), mapOptions);" +
markers +
"}" +
"</script>"
End Sub
Protected Function GetMarkers() As String
Dim markers As String = ""
Using con As New SqlConnection(ConfigurationManager.ConnectionStrings("DefaultConnection").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand("SELECT Lat, Lng, Territory FROM MyMapData", con)
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
Dim i As Integer = 0
While reader.Read()
i = i + 1
markers = markers + "var marker" + i.ToString() + "= new google.maps.Marker({" +
"position: new google.maps.LatLng( " + reader("Lat").ToString() + ", " +
reader("Lng").ToString() + ")," +
"Label:'" + reader("RecordID").ToString() + "', " +
"map: myMap," +
"title:'" + reader("RecordID").ToString() + "'});"
End While
con.Close()
End Using
Return markers
End Function
End Class
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.