ASP.NET Google Map Markers (pushpins) and informatrion display box
I have a small project where I google map several records from my SQL database. The table has just a Latitude, Longitude and a unique record number fields. I managed to display my records on the map and show the record ID in the pushpin (label) as well in the information box when you click with the mouse over a pin (See screenshot). The problem is that the pushpin display only the first digit (I guess because of the pin size and/or the font size used by the system) of the record ID and I have about 150 records in my table. The "information box" does show the full number (See screenshot) however, if accessing the page with an iOS device, I have no idea how to brig the information box up - if there is a way. It is important for iPhone to be able to see the full Record ID in one way or another. Please be specific in you solution since I have a very limited experience in ASP.NET VB.NET. Thank you all
Imports System.DataImports System.ConfigurationImports System.Data.SqlClientPublic 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 FunctionEnd Class
Thank you Robberbaron! Because I am new to ASP.NET I am afraid you lost me :-) All I want is to be able to see up to 3-digits in the Pushpin (if possible - by enlarging the pushpin or reducing the font), this will assure compatibility with Windows and iOS systems which has no mouse clicking ability. Will integrating your idea work? If so, would you be so kind to help me out with the coding?
Thank you!
Robberbaron (robr)
1. i dont think enlarging the pin is possible. I dont even know how your pins work as I had to use Icons; each icon comes as an image of that number.
2. all the browsers support 'click' but perhaps you have to add the listener.... I copied code from examples on google web site. That is where I set the width of the text that pops up.
Thank you!