For example I have ArcGIS REST API as
us high way state city county
I want to see it on Google Maps.
How do I do it?
arcgis-rest-apigoogle maps
For example I have ArcGIS REST API as
us high way state city county
I want to see it on Google Maps.
How do I do it?
In Arc 10.2 you can use IMapServerRESTLayer. Using this avoids using SOAP. Here is some code (VB.Net) that shows how it is used, with some extra code. This code is for a AddIn button. The extra code checks if the connection is OK by requesting a json file. Also, there is code for displaying the json file, and getting the REST file general information. I have not figured out a way of getting the other layer properties such as those under the source tab i.e. Data Type.
The url is typical. You need to find the url by going to the web service and looking it up.
There are other ways of NOT using SOAP. This article by Anthony Baker talks about using json files to consume REST services. Also the background information in http://rest.elkstein.org/2008/02/what-is-rest.html is very good.
Here is the code (tested under Arc10.2) Protected Overrides Sub OnClick() Const csProceedureName As String = "cmdListBaseMap_OnClick" MsgBox("In text version")
Try
Dim pApp As IApplication
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pView As IActiveView
Dim resturl As String
resturl = "http://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Topographic/ImageServer/?f=lyr" ' v2 ' works
' there was a problem getting the interface to work.
' In addition to carto needed to include ESRI.ArcGIS.DataSourceRaster
Dim RESTLayer As IMapServerRESTLayer
RESTLayer = New MapServerRESTLayer
Dim pLayer As ILayer
pApp = My.ArcMap.Application
pMxDoc = pApp.Document
pMap = pMxDoc.FocusMap
pView = pMxDoc.ActiveView
' this is done to test the connection
' Use web HttpWebRequest to see if connection OK and so can retrieve file
Dim request_json_url As String = "http://services.thelist.tas.gov.au/arcgis/rest/services/Basemaps/Topographic/ImageServer/?f=json"
Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create(request_json_url), HttpWebRequest)
Dim response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse)
If response.StatusCode = HttpStatusCode.OK Then
' connection and response OK
'MsgBox("Status Code " & response.StatusCode & vbNewLine & " Status description " & response.StatusDescription & vbNewLine & " Encoding " & response.CharacterSet)
'' this is one method of getting the json file
''Dim encoding As Text.Encoding = System.Text.Encoding.GetEncoding(response.CharacterSet)
''Dim reader As New StreamReader(response.GetResponseStream(), encoding)
''Dim streamtext As String = reader.ReadToEnd()
''MsgBox(streamtext)
' '' use a webclient to check connection, the try cast does exception handling
''Dim wc As WebClient = New WebClient
''Dim response_client As String
'' response_client = wc.DownloadString(request_json_url)
'' MsgBox(response_client)
' Get the Rest layer
RESTLayer.Connect(resturl)
RESTLayer.TransparentBackground(True)
' Cast to ILayer so it can be added to map
' this cast works
pLayer = TryCast(RESTLayer, ILayer)
If pLayer Is Nothing Then
MsgBox("ERROR ( " & csProceedureName & ") Cast from MapServerRESTLayer to Ilayer failed")
Else
'MsgBox("Cast from MapServerRESTLayer to Ilayer OK")
End If
' add layer to map
pMap.AddLayer(pLayer)
pView.Refresh()
'' This works
'' Returns the Description
'' Dim pGenProperties As ILayerGeneralProperties
''pGenProperties = TryCast(pLayer, ILayerGeneralProperties)
''If pGenProperties Is Nothing Then
'' MsgBox("No general properties")
''Else
'' MsgBox("Properties -" & pGenProperties.LayerDescription & "-")
''End If
Else
MsgBox("ERROR ( " & csProceedureName & " ) " & response.StatusCode & vbNewLine & response.StatusDescription)
End If
Catch ex As Exception
MsgBox("Error " & ex.Message)
End Try
End
You need to make a request to the ?query
endpoint of the layer, and supply a where
clause. Specify &f=json
to receive the response in JSON.
Note that ArcGIS Server by default only returns the first 1000 records, so you may need to batch your requests using OBJECTID ranges as the where clause until you've retrieved all records, using this syntax:
That is, use where objectid < 999 in the first request, then where objectid >= 1000 and objectid < 1999, etc, until there are no more responses.
See Converting ArcGIS Server JSON to GeoJSON to convert this JSON response to GeoJSON
Best Answer
You can find 3700+ arcgis server rest api overlay on google at
https://transparentgov.net/cleargov1/931/arcgis-server-3700-from-mappingsupport-com
Share my working code: working sample on jsfiddle
the key is:
On google map, use overlay custom image. The overlay image size is the map div container width and height. The overlay image bound is google map, getBound, lat, lng etc... see code for details.
Note: Overlay tiled coordinate map on google map will NOT works.
failed sample overlay coordinated tiles from arcgis rest api export map
2 reason, first is arcgis rest api export image, does not seemlessly tiled. So you will see distorted, stretched tiled image, mismatch, not workable.
Second reason, arcgis rest api export image, are NOT tiled, the labeling will duplicate in one tile and the tile next to it. For example, if New York State cross 3 tiles, you will see 3 times New York label in each of 3 tiles. duplicated label is not workable.
So if you want to overlay coordinate tiled image on google maps, you must use arcgis rest api with tiled service, regular export map will NOT work.
working sample on jsfiddle