<%@ 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
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE