RSS

A Message Board, Guestbook, or Poll hosted for your website.
Iron Speed Technical Forums

Iron Speed > Forums > Code Customizations V6.X > Bing Maps Anyone?
 
Username:
Password:
 

Thread Tools Search This Thread 
Reply
 
Author Comment
 
ReubenJ
Registered: 10/16/07
Posts: 23

    11/04/09 at 01:11 PM
Reply with quote#1

Has anyone integrated Bing Maps or Virtual Earth with ISD?  I am interested in using the feature that copies coordinates to the clipboard and changing it to update a LAT and LONG field in a record control.

I've already created a number of custom VE/Bing Maps with varying features, but all in VS2005.  I have not been successful in getting the BingMap SDK integrated with IronSpeed.  The main issue is firing a javascript function (GetMap) at the server.  VS2005 uses the body tag:     The javascript function is embedded between the tags.

If anyone has any ideas, I would appreciate hearing them.  Thanks much.
miles
Avatar / Picture

MVP Consultant
Registered: 10/15/03
Posts: 2,254

    11/06/09 at 01:12 PM
Reply with quote#2

try using RegisterStartupScript to register the Javascript on Page Load.  That technique works well in Iron Speed.

HTH,

__________________
Miles Gibson, I.S.P., ITCP
Iron Speed MVP
Senior Consultant, Principal,
Milestone Software
http://www.milesgibson.net
http://www.milestone.ca
ReubenJ
Registered: 10/16/07
Posts: 23

    11/06/09 at 02:42 PM
Reply with quote#3

I tried that technique earlier today.  My implementation might not be all that great.  Here is a description of how I added the map:

1.  Reviewed the Bing Map SDK and used their source code as a template.  http://www.microsoft.com/maps/isdk/ajax/

2.  Put the header tags in ISD's Page Directives for the Master Page.

3.  Added the onload snipit to the body tag:    This is the step that failed.  Onload was not a member of the page.

4.  Next, I tried to attach the code to a button.  It works, but the map disappears within a second of the button click.  I presume the map goes out of scope when the click event finishes.

5.  Next I tried to fire the GetMap function at the end of the LoadData Sub.  No go, ISD didn't recognize the function.

6.  Then I tried the RegisterStartupScript in the LoadData Sub but got the same results, either the GetMap function was not found or the map appeared for less than a second. 

7.  Lastly, I tried the RegisterStartupScript in the Page_Load with the same results as #6.

Several of my tries are listed below:

Code:
 Public Sub LoadData() ' LoadData reads database data and assigns it to UI controls.
' Customize by adding code before or after the call to LoadData_Base()
' or replace the call to LoadData_Base().
LoadData_Base()
' Dim si As New HtmlGenericControl
' si.TagName = "script"'
' si.Attributes.Add("type", "javascript")
' si.Attributes.Add("src", "/BingMap.js")
' Header.Controls.Add(si)
'btn.Attributes.Add("onclick", "MyFunction()")
PushButton.Attributes.Add("onclick", "GetMap()")

End Sub
?
Protected Sub MyLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' add your code here
If (Not Me.IsStartupScriptRegistered("GetMap")) Then
' Form the script to be registered at client side.
Dim scriptString As String = " var map = null; "
'
scriptString += "function GetMap() {"
scriptString += "map = new VEMap('myMap'); "
scriptString += "map.LoadMap(); "
scriptString += "} "
Me.RegisterStartupScript("GetMap", scriptString)
'GetMap()
End If
End Sub


I would really appreciate any other suggestions.

Thanks, Reuben

ReubenJ
Registered: 10/16/07
Posts: 23

    11/10/09 at 03:51 PM
Reply with quote#4

  Yeah!!!  I finally found the right combination to get a map on the page.  Follow these steps if you want to take a shot at it.  Also, let me know if you have any enhancements.

1.  Put your Bing Map java code into a separate .js file.  This is the content of my BingMap.js:

 

         function GetMap()
        {
           var map = null;          
           map = new VEMap('myMap');
           map.LoadMap(new VELatLong(32.8, -100.5), 8 ,'r' ,false); 
        }

 

2.  In the master page, page directives header section, add a reference to your javascript file:

  

<Scripts> <asp:ScriptReference Path="~/SetFocus.js" /> <asp:ScriptReference Path="~/BingMap.js"/> Scripts>  asp:ScriptManager>

  

3.  On the page you want a Bing Map, open the page directives:

 

a.  In the page prolog, after the StartOfPageContent tag, add this script reference:

 

<a id="StartOfPageContent">a>

 

<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2">script>   

 

    <GEN:UPDATEPANEL NAME="UpdatePanel1">

 

b.  In the page epilog, add the script below.

 

GEN:UPDATEPANEL>

    <div id="detailPopup" class="detailRolloverPopup" onmouseout="detailRolloverPopupClose();" onmouseover="clearTimeout(gPopupTimer);">div>

   

      <script type="text/JavaScript">

 

      window.onload = GetMap ()

 

      script> 

     

      <asp:ValidationSummary id="ValidationSummary1" ShowMessageBox="true" ShowSummary="false" runat="server">asp:ValidationSummary>

asp:Content>

 

 

4.  On the page where you want the Bing Map, choose a cell to place the actual map:

 

<div id='myMap' style="position:relative; width:550px; height:400px;">div>

 

Voila, you should have a Bing Map on your ISD page.

 

Note:  I did not try to add the map inside of an IronSpeed Table or Record control.  I placed the map in a cell outside of all generated controls.  The next step is to add javascript to interact with the individual database bound controls and hopefully pass information from the map to the database.

 

timt
Avatar / Picture

Iron Speed MVP
Consulting Organization

Registered: 08/06/05
Posts: 1,113

    11/11/09 at 04:12 AM
Reply with quote#5

Hi

We are currently using the Silverlight control for Bing Maps which is a great solution without the need for Ajax, you could try that?

__________________
Tim Titchmarsh
UK Iron Speed MVP
Dot Net Architect
+44 (0)1621 857758
http://www.dotnetarchitect.co.uk
timt@dotnetarchitect.co.uk
ReubenJ
Registered: 10/16/07
Posts: 23

    11/12/09 at 06:13 AM
Reply with quote#6

Unfortunately, our enterprise hq has not approved Silverlight for use.  If I use 'unauthorized' tools, I become a 'rogue' programmer!

Previous Thread | Next Thread
Reply

 
Bookmarks
 
Digg Diggdel.icio.us del.icio.usStumbleUpon StumbleUponGoogle Google
 
Download Iron Speed Designer

Privacy Statement