Select to view content in your preferred language

doubts regarding esri map to googlemap

2669
9
Jump to solution
06-11-2012 04:29 AM
JulieBiju
Deactivated User
I have few doubts regarding linking of ESRI based application with GoogleMap.
I developed one  ESRI silverlight web based application .In ths i added some graphics with picturemarker .Information Window added for tooltip.Everything is working fine.

we purchased ArcGIS 10 Desktop  and ArcGIS server
1.I need this same application with Googlemap.Instead of following map ..

 <esri:Map Extent="-120, 20, -100, 40"  Grid.Row="3" Name="MyMap"  Visibility="Visible" Background="Transparent" Margin="2,0" BorderThickness="1" BorderBrush="{StaticResource TitleBarGradient}">           <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />                            <esri:GraphicsLayer ID="MyGraphicsLayer" />         </esri:Map>

is it possible?

2.Any samples is available for loading Googlemap with API key ,  here in this link http://help.arcgis.com/en/webapi/silverlight/samples/start.htm


3.Bing map or googlemap which is better?whether both are free services or not???

4.I developed one asp.net web based application for acceesiing the googlemap .Is it required to change this application from asp.net to silverlight based application?


regards
0 Kudos
1 Solution

Accepted Solutions
JoeHershman
MVP Alum
Ok Joe let me try.  Now the things is working fine in vb.net. I have a problem in one line of code

If CInt(lod.Resolution) <= CInt(Math.Truncate(currentResolution)) Then


This line i am getting error
truncate is not a member of system.math

1.how can i write this line in another way for same result?



Sorry don't know enough VB anymore and don't have a VB dev environment to test it.


2.i generated google API key ,in this project where i need to specify google API kety???


I don't know how you use Google API keys

3.Whether it is legal to use Google API key or not?We have licence of arcgis desktop10 and arcgis server.


That you have to take up with Google.  ArcGIS 10 and ArcGIS Server licensing have nothing to do with Google licensing.

Good Luck
-Joe
Thanks,
-Joe

View solution in original post

0 Kudos
9 Replies
JoeHershman
MVP Alum
There is nothing along the lines of a Silverlight control for google maps (certainly none I am aware of).  To use google maps you would have to use their API which would mean doing things in javascript.  If you are using Silverlight your options are ArcGIS Online and Bing.

Both services have their own licensing agreements and it really depends on how you plan on using your site what you would be required to buy and what it costs.  For development you can get a limited use Bing key

Good luck
-Joe
Thanks,
-Joe
0 Kudos
JulieBiju
Deactivated User
There is nothing along the lines of a Silverlight control for google maps (certainly none I am aware of). 
Good luck
-Joe


Ok.Then how this link is  explaining working http://rexdotnet.blogspot.com/2010/09/use-google-maps-with-arcgis-silverlight.html
I downloaded sample application from this page.But i cannot open the solution in VS2010
0 Kudos
JenniferNery
Esri Regular Contributor
Hmm. I was able to download and open the sample in VS 2010 (Version 10.0.40219.1 SP1Rel). I just had to update references and replace ScaleBar with ScaleLine. http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Scaleline
0 Kudos
JulieBiju
Deactivated User
Hmm. I was able to download and open the sample in VS 2010 (Version 10.0.40219.1 SP1Rel). I just had to update references and replace ScaleBar with ScaleLine. http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Scaleline


Dear friend, Now i can open this project in VS2010 .Is it possible to add imagery button and hybrid button over here?
0 Kudos
JoeHershman
MVP Alum
Interesting post, thanks.

In the mapUrl returned the maptype is defined


                mapURL = string.Format
                  ("http://maps.google.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&maptype=roadmap&sensor=false",
                   geogCenterPoint.Y, geogCenterPoint.X, currentLodIndex, requestWidth, requestHeight);



Seems you could make two other Google layer classes nearly identical to the one Rex provides but one would have maptype=satellite and one maptype=hybrid (https://developers.google.com/maps/documentation/staticmaps/#MapTypes). When the user clicks the button either add/remove layers or set the Visible property accordingly.  I would test, but the environment I work in does not allow outside access from our development machines

Good luck
-Joe
Thanks,
-Joe
0 Kudos
JulieBiju
Deactivated User
Interesting post, thanks.

In the mapUrl returned the maptype is defined


                mapURL = string.Format
                  ("http://maps.google.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&maptype=roadmap&sensor=false",
                   geogCenterPoint.Y, geogCenterPoint.X, currentLodIndex, requestWidth, requestHeight);



Seems you could make two other Google layer classes nearly identical to the one Rex provides but one would have maptype=satellite and one maptype=hybrid (https://developers.google.com/maps/documentation/staticmaps/#MapTypes). When the user clicks the button either add/remove layers or set the Visible property accordingly.  I would test, but the environment I work in does not allow outside access from our development machines

Good luck
-Joe



Ok Joe let me try.  Now the things is working fine in vb.net. I have a problem in one line of code

If CInt(lod.Resolution) <= CInt(Math.Truncate(currentResolution)) Then


This line i am getting error
truncate is not a member of system.math


1.how can i write this line in another way for same result?

2.i generated google API key ,in this project where i need to specify google API kety???

3.Whether it is legal to use Google API key or not?We have licence of arcgis desktop10 and arcgis server.
0 Kudos
JoeHershman
MVP Alum
Ok Joe let me try.  Now the things is working fine in vb.net. I have a problem in one line of code

If CInt(lod.Resolution) <= CInt(Math.Truncate(currentResolution)) Then


This line i am getting error
truncate is not a member of system.math

1.how can i write this line in another way for same result?



Sorry don't know enough VB anymore and don't have a VB dev environment to test it.


2.i generated google API key ,in this project where i need to specify google API kety???


I don't know how you use Google API keys

3.Whether it is legal to use Google API key or not?We have licence of arcgis desktop10 and arcgis server.


That you have to take up with Google.  ArcGIS 10 and ArcGIS Server licensing have nothing to do with Google licensing.

Good Luck
-Joe
Thanks,
-Joe
0 Kudos
JulieBiju
Deactivated User
......could make two other Google layer classes nearly identical to the one Rex provides but one would have maptype=satellite and one maptype=hybrid (...ks the button either add/remove layers or set the Visible property accordingly...e


Dear joe ,
I did the things what u mentioned here.Hope everything is working fine.I am pasting code below.When i start te3sting my aplication it was working fine. But After 10 times of testing the application,  googlemap is not showing.I can able to  zoom but googlemapmap is not displaying.

1.Can u help me what is the problem behind this?See the creen shot.


2.How can i remove small square icon from the map.(See the screenshot)


Private Sub RadRoadMap_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles RadRoadMap.Checked
        MyMap.Layers("222").Visible = True
        MyMap.Layers("111").Visible = False
    End Sub

    Private Sub RadSatellite_Checked(sender As Object, e As System.Windows.RoutedEventArgs) Handles RadSatellite.Checked
        MyMap.Layers("222").Visible = False
        MyMap.Layers("111").Visible = True
    End Sub


<esri:Map x:Name="MyMap" Grid.Row="3" SnapToLevels="True" Visibility="Visible" Background="Transparent" Margin="2,0" BorderThickness="1" BorderBrush="{StaticResource TitleBarGradient}">
            <esri:Map.Template>
                <ControlTemplate>
                    <Grid Background="{TemplateBinding Background}">
                        <Grid x:Name="RootElement" Width="Auto" Height="Auto" />
                        <Rectangle x:Name="ZoomBox" Fill="#55FFFFFF" Stroke="Green" StrokeThickness="2" Visibility="Collapsed" />
                        <esri:ScaleBar x:Name="MyScaleBar" Margin="75,5,5,5" MapUnit="Meters" TextColor="Black" HorizontalAlignment="Left" VerticalAlignment="Bottom" DisplayUnit="Miles" Map="{Binding ElementName=MyMap}" />
                    </Grid>
                </ControlTemplate>
            </esri:Map.Template>
            <esri:Map.Layers>
                <customLayers:MercatorSchemaTiledLayer Visible="False" />
                <customLayers:GoogleStaticMapLayer ID="222"/>
                <esri:ArcGISDynamicMapServiceLayer ID="OperationalLayer" Opacity="0.7" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyOperationalLayers/MapServer" />
              
                <customLayers:MercatorSchemaTiledLayer Visible="False" />
                <customLayers:GoogleStaticMapLayerSatellite ID="111" Visible="False"/>
                <esri:ArcGISDynamicMapServiceLayer ID="OperationalLayer1" Visible="False" Opacity="0.7" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyOperationalLayers/MapServer" />
                 
                <esri:GraphicsLayer ID="MyGraphicsLayer" />
            </esri:Map.Layers>
        </esri:Map>


Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Geometry

Public Class GoogleStaticMapLayerSatellite
    Inherits DynamicMapServiceLayer
    Private Shared mercator As New ESRI.ArcGIS.Client.Projection.WebMercator()

    Private Const cornerCoordinate As Double = 20037508.3427892
    Private Const WKID As Integer = 102100

    Public Sub New()
        MyBase.New()
    End Sub

    Private Property Lods() As Lod()
        Get
            Return m_Lods
        End Get
        Set(value As Lod())
            m_Lods = value
        End Set
    End Property
    Private m_Lods As Lod()

    Public Overrides Sub Initialize()
        Me.FullExtent = New ESRI.ArcGIS.Client.Geometry.Envelope(-cornerCoordinate, -cornerCoordinate, cornerCoordinate, cornerCoordinate) With { _
         .SpatialReference = New SpatialReference(WKID) _
        }

        Me.SpatialReference = New SpatialReference(WKID)

        Lods = New Lod(20) {}
        Dim resolution As Double = cornerCoordinate * 2 / 256
        For i As Integer = 0 To Lods.Length - 1
            Lods(i) = New Lod() With { _
              .Resolution = resolution _
            }
            resolution /= 2
        Next

        MyBase.Initialize()
    End Sub

    Public Overrides Sub GetUrl(extent As ESRI.ArcGIS.Client.Geometry.Envelope, width As Integer, height As Integer, onComplete As DynamicMapServiceLayer.OnUrlComplete)
        Dim geogCenterPoint As MapPoint = Nothing
        Dim mapURL As String = Nothing

        Try
            'If width > 640 OrElse height > 640 Then
            '    Throw New Exception("Width or height greater than 640")
            'End If

            Dim currentResolution As Double = extent.Width / width
            Dim currentLodIndex As Integer = 0
            Dim requestWidth As Integer = 0
            Dim requestHeight As Integer = 0
            For i As Integer = 0 To Lods.Length - 1
                Dim lod As Lod = Lods(i)
                currentLodIndex = i
                'If CInt(lod.Resolution) <= CInt(Math.Truncate(currentResolution)) Then
                If CInt(lod.Resolution) <= CInt((currentResolution)) Then
                    requestWidth = CInt(extent.Width / lod.Resolution)
                    requestHeight = CInt(extent.Height / lod.Resolution)
                    Exit For
                End If
            Next

            'If requestWidth > 640 OrElse requestHeight > 640 Then
            '    Throw New Exception("Request width or height greater than 640")
            'End If

            geogCenterPoint = TryCast(mercator.ToGeographic(extent.GetCenter()), MapPoint)


            mapURL = String.Format("http://maps.google.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&scale=2&maptype=satellite&sensor=false", geogCenterPoint.Y, geogCenterPoint.X, currentLodIndex, requestWidth, requestHeight)

        Catch ex As Exception
            ' Message box just for debug purposes
            'System.Windows.MessageBox.Show( ex.Message,"Error: Google Static Map not generated", System.Windows.MessageBoxButton.OK); 
            Return
        End Try

        onComplete(mapURL, width, height, New ESRI.ArcGIS.Client.Geometry.Envelope() With { _
          .XMin = extent.XMin, _
          .YMin = extent.YMin, _
          .XMax = extent.XMax, _
          .YMax = extent.YMax _
        })
    End Sub
End Class


Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Geometry

Public Class GoogleStaticMapLayer
    Inherits DynamicMapServiceLayer
    Private Shared mercator As New ESRI.ArcGIS.Client.Projection.WebMercator()

    Private Const cornerCoordinate As Double = 20037508.3427892
    Private Const WKID As Integer = 102100

    Public Sub New()
        MyBase.New()
    End Sub

    Private Property Lods() As Lod()
        Get
            Return m_Lods
        End Get
        Set(value As Lod())
            m_Lods = Value
        End Set
    End Property
    Private m_Lods As Lod()

    Public Overrides Sub Initialize()
        Me.FullExtent = New ESRI.ArcGIS.Client.Geometry.Envelope(-cornerCoordinate, -cornerCoordinate, cornerCoordinate, cornerCoordinate) With { _
         .SpatialReference = New SpatialReference(WKID) _
        }

        Me.SpatialReference = New SpatialReference(WKID)

        Lods = New Lod(20) {}
        Dim resolution As Double = cornerCoordinate * 2 / 256
        For i As Integer = 0 To Lods.Length - 1
            Lods(i) = New Lod() With { _
              .Resolution = resolution _
            }
            resolution /= 2
        Next

        MyBase.Initialize()
    End Sub

    Public Overrides Sub GetUrl(extent As ESRI.ArcGIS.Client.Geometry.Envelope, width As Integer, height As Integer, onComplete As DynamicMapServiceLayer.OnUrlComplete)
        Dim geogCenterPoint As MapPoint = Nothing
        Dim mapURL As String = Nothing

        Try
            'If width > 640 OrElse height > 640 Then
            '    Throw New Exception("Width or height greater than 640")
            'End If

            Dim currentResolution As Double = extent.Width / width
            Dim currentLodIndex As Integer = 0
            Dim requestWidth As Integer = 0
            Dim requestHeight As Integer = 0
            For i As Integer = 0 To Lods.Length - 1
                Dim lod As Lod = Lods(i)
                currentLodIndex = i
                'If CInt(lod.Resolution) <= CInt(Math.Truncate(currentResolution)) Then
                If CInt(lod.Resolution) <= CInt((currentResolution)) Then
                    requestWidth = CInt(extent.Width / lod.Resolution)
                    requestHeight = CInt(extent.Height / lod.Resolution)
                    Exit For
                End If
            Next

            'If requestWidth > 640 OrElse requestHeight > 640 Then
            '    Throw New Exception("Request width or height greater than 640")
            'End If

            geogCenterPoint = TryCast(mercator.ToGeographic(extent.GetCenter()), MapPoint)


            mapURL = String.Format("http://maps.google.com/maps/api/staticmap?center={0},{1}&zoom={2}&size={3}x{4}&scale=2&maptype=roadmap&sensor=false", geogCenterPoint.Y, geogCenterPoint.X, currentLodIndex, requestWidth, requestHeight)
            
        Catch ex As Exception
            ' Message box just for debug purposes
            'System.Windows.MessageBox.Show( ex.Message,"Error: Google Static Map not generated", System.Windows.MessageBoxButton.OK); 
            Return
        End Try

        onComplete(mapURL, width, height, New ESRI.ArcGIS.Client.Geometry.Envelope() With { _
          .XMin = extent.XMin, _
          .YMin = extent.YMin, _
          .XMax = extent.XMax, _
          .YMax = extent.YMax _
        })
    End Sub
End Class
0 Kudos
JoeHershman
MVP Alum
Julie,

Sorry but I really don't know much more about it than what is in the article that you found.  I just kind of set it up to see how it worked, but have not done anything with it other than that.  Wish I could be more help, but I just don't know anything more

Good Luck
Thanks,
-Joe
0 Kudos