[AccessD] Mappoint - Virtual Earth - and Access Db

MartyConnelly martyconnelly at shaw.ca
Sun Oct 1 14:51:10 CDT 2006


You can store pushpins in a table and then bring in through a javascript 
array with VEPushPin
but the common way is to use a layer with an RSSGeo.xml  file, this is a 
W3C standard.
You can add and delete various layers. I have heard of people using 
30,000 pushpins.

You can then add text and images to the mouseclick or hover over the 
pushpin.

Look through the forums here for more info
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=462045&SiteID=1

You can also do route maps  by specifying place names or full street address
province/state country and print out driving distance. Takes 10 seconds


<html>
   <head>
      <title>Push Pin</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script 
src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
      <script>
         var map = null;
         var layerid=1;
              function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();
            VEPushpin.ShowDetailOnMouseOver = True;
         }  
         //Add first layer
         function AddMyLayer()
         {
            var veLayerSpec = new VELayerSpecification(
        VELayerType.GeoRSS, //Layer type
        "2", //ID - must be unique
        "http://dev.live.com/virtualearth/sdk/GeoRssTest.xml", //source
        "get", //download method
          null,null);
            map.AddLayer(veLayerSpec);
           layerid++;
            }

         function onFeedLoad(feed)
         {
            alert('RSS or Collection loaded. There are '+feed.length+' 
items in this list.');
         }
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:400px; 
height:400px;"></div>
      <INPUT id="loadFeed" type="button" value="Load GeoRSS xml" 
name="loadFeed"
        onclick="AddMyLayer(VELayerType.GeoRSS);">
  
   </body>
</html>


<html><head><title>Route Map History</title></head>
<script 
src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>
<script language="javascript" type="text/javascript">
     var map;
     var pin;
     var pin1;
    var pin2;
    function GetMap ()
{
         map = new VEMap ("myMap")
         map.LoadMap(new VELatLong(48.51, -123.36), 10 ,"h" ,false)
         map.GetRoute("microsoft", "area 51",null,null,onGotRoute)
}
function onGotRoute(route)
{
   var routeinfo="Route info:\n\n";
   routeinfo += "Total distance: ";
   routeinfo += route.Itinerary.Distance+" ";
   routeinfo += route.Itinerary.DistanceUnit+"\n";

   var steps="";
   var len = route.Itinerary.Segments.length;
   for(var i = 0; i<len ;i++)
   {
      steps+=route.Itinerary.Segments[i].Instruction+" -- (";
      steps+=route.Itinerary.Segments[i].Distance+") ";
      steps+=route.Itinerary.DistanceUnit+"\n";
   }
   routeinfo += "Steps:\n"+steps;
   alert(routeinfo);
}
</script>
<body onload='GetMap();'>
<div id='myMap' style='position:relative; width:600px; height:400px;'></div>
</body>
</html>

David Gray wrote:

>Really cool Marty! Thanks!
>
>What else can you do?
>
>Do you know how to store pushpins in a table?
>
>David Gray
>96 Springacre Rd
>Thornlands QLD
>Yahoo ID: flock_it_software
> 
> 
>
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
>Sent: Friday, 29 September 2006 12:34 PM
>To: Access Developers discussion and problem solving
>Subject: Re: [AccessD] Mappoint - Virtual Earth - and Access Db
>
>
>For those of you wanting to footle around with Access and MS Virtual Earth
>Here is some sample code, it also dumps the html code to an html file By
>clicking  on map you  display Lat/Long position of cursor
>
>Option Compare Database
>Option Explicit
>
>
>Function testVirtualEarthMap()
>'------------------
>'display Virtual Earth at a fixed LatLong
>' then  click on map to display Lat/Long position of cursor 'see these for
>info: 'http://dev.live.com/virtualearth/sdk/
>'http://www.ftponline.com/special/web20/pvarholasp/default.aspx
>
>Dim objExplorer As Object
>Dim objDocument As Object
>Dim strHTML As String
>
>Set objExplorer = CreateObject("InternetExplorer.Application")
>
>objExplorer.Navigate "about:blank"
>objExplorer.Toolbar = 1 ' 0= off
>objExplorer.StatusBar = 1 '0 =off
>objExplorer.Width = 800
>objExplorer.Height = 870
>objExplorer.Left = 0
>objExplorer.Top = 0
>objExplorer.Visible = 1
>
>Do While (objExplorer.Busy)
>Loop
>
>
>Set objDocument = objExplorer.Document
>objDocument.Open
>'create html string and dump to a test file
> strHTML = ""
> strHTML = strHTML & createhtml
>
>WriteFile "c:\gis\test.html", strHTML
>
>'objDocument.Writeln strHTML
>objDocument.Write strHTML
>objExplorer.Refresh ' ??This has to be done because of 
>http://local.live.com/veapi.ashx
>'objDocument.Close 'stall here
>Do While (objExplorer.Busy)
>Loop
>'MsgBox "finished"
>'Set objExplorer = Nothing
>'Set objDocument = Nothing
>
>End Function
>
>Private Sub WriteFile(ByVal sFileName As String, ByVal sContents As String)
>' Dump XML or html String to File for debugging
>    Dim fhFile As Integer
>    fhFile = FreeFile
>   ' Debug.Print "Length of string=" & Len(sContents)
>    Open sFileName For Output As #fhFile
>    Print #fhFile, sContents;
>    Close #fhFile
>    Debug.Print "Out File" & sFileName
>End Sub
>
>Function createhtml() As String
>
>Dim strHTML As String
> strHTML = ""
> strHTML = strHTML & "<html><head><title>Virtual Earth Map</title></head>"
>  strHTML = strHTML & "<meta http-equiv=""Content-Type"" 
>content=""text/html; charset=utf-8"">"
>'When your page has referenced the map control, set up the call to 
>display a default map by completing a LoadMap ( ) method call:  strHTML =
>strHTML & vbCrLf & "<script 
>src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> " '
>strHTML = strHTML & vbCrLf & "<script type='text/javascript' 
>src='http://local.live.com/veapi.ashx'></script>"
> strHTML = strHTML & vbCrLf & "<script language=""javascript"" 
>type=""text/javascript"">"
>  
>
>'  strhtml = strhtml & vbCrLf & "<!-- "
> strHTML = strHTML & vbCrLf & "     var map=null;"
> 
> strHTML = strHTML & vbCrLf & " function ShowLatLon(e)"
> strHTML = strHTML & vbCrLf & "        {"
> strHTML = strHTML & vbCrLf & "alert('Latitude = ' + 
>e.view.LatLong.Latitude + 'Longitude = ' + e.view.LatLong.Longitude);"
> strHTML = strHTML & vbCrLf & "       }"
> strHTML = strHTML & vbCrLf & "  function GetMap()"
> strHTML = strHTML & vbCrLf & " { "
> strHTML = strHTML & vbCrLf & "         map = new VEMap(""myMap"");"
> strHTML = strHTML & vbCrLf & "map.onLoadMap = function(){ alert('The 
>map has loaded.') };"
>
> strHTML = strHTML & vbCrLf & "         map.LoadMap(new VELatLong(48.51, 
>-123.36), 10 ,""h"" ,false);"
> strHTML = strHTML & vbCrLf & "    map.AttachEvent(""onclick"", 
>ShowLatLon);"
> strHTML = strHTML & vbCrLf & " }"
> strHTML = strHTML & vbCrLf & "</script>"
>' strhtml = strhtml & vbCrLf & "// -->"
>'Last, you display the map:
>
> strHTML = strHTML & vbCrLf & "<body onload='GetMap();'>"  strHTML = strHTML
>& vbCrLf & "<div id='myMap' style='position:relative; 
>width:600px; height:600px;'></div>"
> strHTML = strHTML & vbCrLf & "<td> right or left click map for latitude 
>longitude position </td>"
> strHTML = strHTML & vbCrLf & "</body>"
> strHTML = strHTML & vbCrLf & "</html>"
>WriteFile "c:\gis\test.html", strHTML
>createhtml = strHTML
>End Function
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada




More information about the AccessD mailing list