[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Google map markers within give radius e.g. 30 miles from SQL server table using classic asp

Posted on 2012-04-04
Medium Priority
Last Modified: 2012-04-09
Hi All,

I'd like to take a dynamically created dataset from a MSSQL database table using classic asp and plot them on a "google maps" map - ideally within a given range of say 30 miles.

For exmaple, I have a MSSQL tables called LocalStores, that have the following data fields;

1. Store Name
2. Store Type
3. Store Latitude
4. Store Longitude

I've signed up for my Google Key, but cannot work out to extract my MSSQL data using Classic ASP and to plot markers onto a Google maps - I also want to customise the markers based on store type.

I'm totally confused with all the options - I also need the maps to work on Windows/Android and Apple devices - with my example code below does not seem to, it only displays on Windows and not iPads etc.

Any help would be greatly and very much appreciated.



My Code  so far;



<%@  language="VBScript" %>
<%Option Explicit%>
<!--#include file="Controls/GoogleMaps.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <title>Google Maps Searcher</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        ' Initialize Google Maps object, which encapsulates all functionality
        Dim googleMaps : Set googleMaps = New ASP2_Controls_GoogleMapsSearcher
'        googleMaps.APIKey = "xxxxx"
             googleMaps.APIKey = xxxxx"
        ' Render UI
            Response.Write "<br><br>Map Drawn - can you see it?<br><br>"

        ' Dispose


Class ASP2_Controls_GoogleMapsSearcher

    ' ///// Member variables//////

    Dim m_apiKey ' As String
    Dim m_ID ' As String
    Dim m_customFieldLabel ' As String
    Dim m_customAttendees ' As String
    Dim m_attributes ' As String

    ' ///// Properties variables//////

    Public Property Get APIKey
        APIKey = m_apiKey
    End Property

    Public Property Let APIKey(value)
        m_apiKey = value
    End Property

    ' ///// Construciton variables//////

    ' Constructor
    Private Sub Class_Initialize
    End Sub

    ' Destructor
    Private Sub Class_Terminate
    End Sub

    ' ///// Public Methods variables//////

    ' Renders the control UI
    Public Sub Render()
<div id="mapsearcher" style="left: 10px; position: relative;">
    <form id="frmsearcher" method="post" action="">
    Area or Zip Code:
    <input type="text" size="30" name="address" id="address" class="required email">&nbsp;&nbsp;
    <input type="text" size="4" name="radius" value='30' id="radius">&nbsp;
    <input id="optMiles" name="group0" type="radio" title="Miles" checked="checked" />Miles&nbsp;
    <input id="optKm" name="group0" type="radio" title="Kilometers" />Km<br />
    <span id="errMsg" style="font-style: oblique; color: Red"></span>
    <input type="button" value="Geocode" onclick="codeAddress();">
<div id="map" style="width: 1000px; height: 600px; top: 10px; left: 10px; position: relative;
    visibility: hidden;">
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=<%=Me.APIKey %>&sensor=false"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script type="text/javascript">
    var geocoder;
    var map;
    var cCircle;
    var addr = "";
    var rad = "";

    $(document).ready(function () {

    function mapLoader() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 9,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        map = new google.maps.Map(document.getElementById("map"), myOptions);

    function codeAddress() {
        addr = $("#address").val();
        rad = $("#radius").val();

        if (map == null) {

        if (validate()) {
            geocoder.geocode({ 'address': addr }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                        title: addr
                    $("#map").css("visibility", "visible");
                } else {
                    $("#errMsg").html("Geocode was not successful for the following reason: " + status + "<br />");

    function makeRadius() {

        if (cCircle != null) {

        if ($('#optMiles').attr('checked') == 'checked') {
            try {
                var rVal;
                rVal = Math.round(1.61 * rad);
                rad = rVal * 1000;
            catch (e) {
                $("#errMsg").html(e.Message + "<br />");
        else {
            rad = rad * 1000;

        var populationOptions = {
            strokeColor: "#FF0000",
            strokeOpacity: 0.8,
            strokeWeight: 2,
            fillColor: "#FF0000",
            fillOpacity: 0.35,
            map: map,
            center: map.center,
            radius: rad
        cCircle = new google.maps.Circle(populationOptions);

    function validate() {

        var regLet = /\d+|\w+/i;
        var regRad = /^(\d+)+$/i;

        if (!regLet.test(addr)) {
            $("#errMsg").html("*Plase type correct Area or Zip code<br />");
            return false;

        if (rad == "") {
            rad = "30";
            return true;

        if (!regRad.test(rad)) {
            $("#errMsg").html("*Plase type correct Radius value<br />");
            return false;

        return true;

    function clearErr() {

   End Sub
End Class

Question by:Jamie
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 82

Expert Comment

ID: 37813895
replace :
    $(document).ready(function () {

Open in new window

by :
    $(document).ready(function () {

Open in new window


Author Comment

ID: 37814072
Hi leakim971,

Many thanks for your reply - the maps are displaying on iPhones etc now - thank you very much - rocking!

Do you know how I would place multiple markers from my SQL database onto the map - I can write the classic asp sql calls, just cannot work out how to feed them into the Google map?


LVL 82

Accepted Solution

leakim971 earned 2000 total points
ID: 37814769
Hi JamWales,

Check this thread, hope it will help you :


Author Closing Comment

ID: 37822649
Hi leakim971 - thank you for all your help, much appreciated. Regards JamWales

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question