Author Topic: From Autocad to google maps  (Read 16834 times)

0 Members and 1 Guest are viewing this topic.

lamarn

  • Swamp Rat
  • Posts: 636
From Autocad to google maps
« on: November 08, 2009, 02:58:35 PM »
Is there a way to pass the coordinats from Autocad to google maps to display..?
(a simple program to let it pop up in your browser from inside Autocad..)
« Last Edit: October 27, 2010, 04:05:46 PM by DinØsaur »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Crank

  • Water Moccasin
  • Posts: 1503
Re: From Autocad tot google maps
« Reply #1 on: November 15, 2009, 10:41:00 AM »
Try this.
Vault Professional 2023     +     AEC Collection

SomeCallMeDave

  • Guest
Re: From Autocad tot google maps
« Reply #2 on: November 16, 2009, 02:24:05 PM »
It has been a while since I did any VBA so please forgive the quality of the code.

You can create a form with a webbrowser control, 2 textboxes (tbLatLong and tbZoom), and one button

Code: [Select]
Private Sub CommandButton1_Click()
 ' sample http request
    'http://maps.google.com/?ll=29,-82&z=18
    'zoom level -  1= whole world, 20= as close as possible
    Dim call_string As String
    Dim lat_long As String
    Dim zoom as String
    lat_long = Me.tbLatLong.Text
    zoom = Me.tbZoom.Text
    call_string = "http://maps.google.com/?ll=" & lat_long & "&z=" & zoom
    Me.WebBrowser1.Navigate call_string
End Sub

In ThisDrawing, add a sub-routine

Code: [Select]
Public Sub ShowMap()
   
    Dim map_form  As UserForm1
    Set map_form = New UserForm1
    map_form.Show

End Sub


You could easily get the viewport center, convert that to latlong and use those coords to center the google map at the center of your drawing.

This link http://mapki.com/wiki/Google_Map_Parameters has more info on google maps http calls.

If you get a googleMaps API key, you can embed the data in your own website and have more control over what is displayed (like polygons, point markers, etc).  http://code.google.com/apis/maps/

I wrote a small Ruby on Rails app that takes polylines from Autocad and displays them on a google map. 

I can post that code if you are interested


Robert98

  • Guest
Re: From Autocad tot google maps
« Reply #3 on: October 24, 2010, 03:04:45 PM »
Hi
I read these notes and codes now . my question is that : " Are these usable for Google earth or that formats and objects not compatible with google maps ? : :|
Thanks for your good tips .

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: From Autocad tot google maps
« Reply #4 on: October 27, 2010, 10:26:52 AM »
It is entirely possible to pass coordinates of a polyline to a google map, however there are many considerations.

First your polyline coordinates must be UTM (i.e. longitude and latitude).
Next, you must have a javascript embedded in your map webbrowser to pass your points.
Finally you have to construct your polyline from the points using the Google API and set it to your map.

There are a few caveats ... a webbrowser control will allow you to invoke a script (remember Javascript is case sensitive), but it will only allow you to pass a single variable. The good news is that variable must be an array of each of the required parameters of your javascript function.

Consider that you have a single marker to display, you might merely need to pass one geocoded point (-112.53412,84.84533) so your javascript function can accept 2 variables, one for longitude and one for latitude, however, if you need to pass an unknown number of verticies, your javascript function will not accept more than it was defined to handle. To resolve this, use a delimited string as the points array then pass the delimiter to your javascript function.

Code: [Select]
'This is our argument array
Dim Args(1) As String
'Build our list of points, X & Y coords (i.e. Lon/Lat)
For N = 0 to polypoints.count - 1
Args(0) = Args(0) & polypoints(N).X & "," & polypoints(N).Y
Next
'Pass our delimiter
Args(1) = ","
'Call the script
WebBrowser1.document.InvokeScript("MakePoly",Args)

Code: [Select]
function MakePoly(points, delimiter){
//you need to unpack your points using the delimiter
//and create an array of GLatLng for API V2 or LatLng for API V3
//polyline building code goes here
}

Before I catch heat, I haven't used VBA for some time, so the example may contain errors .. specifically with the AutoCAD objects ... I can't believe how fast I forget these things ...

Incidently, you can also return the value of the function as a com object to your calling function, but there is no documentation on how to interact with it, although I have made some progress, it is hit and miss for the most part, although strings and markers return nicely and are relatively easy to interact with and manipulate.

Good luck!
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Robert98

  • Guest
Re: From Autocad tot google maps
« Reply #5 on: October 27, 2010, 01:52:48 PM »
It is entirely possible to pass coordinates of a polyline to a google map, however there are many considerations.

First your polyline coordinates must be UTM (i.e. longitude and latitude).
Next, you must have a javascript embedded in your map webbrowser to pass your points.
Finally you have to construct your polyline from the points using the Google API and set it to your map.

There are a few caveats ... a webbrowser control will allow you to invoke a script (remember Javascript is case sensitive), but it will only allow you to pass a single variable. The good news is that variable must be an array of each of the required parameters of your javascript function.

Consider that you have a single marker to display, you might merely need to pass one geocoded point (-112.53412,84.84533) so your javascript function can accept 2 variables, one for longitude and one for latitude, however, if you need to pass an unknown number of verticies, your javascript function will not accept more than it was defined to handle. To resolve this, use a delimited string as the points array then pass the delimiter to your javascript function.

Code: [Select]
'This is our argument array
Dim Args(1) As String
'Build our list of points, X & Y coords (i.e. Lon/Lat)
For N = 0 to polypoints.count - 1
Args(0) = Args(0) & polypoints(N).X & "," & polypoints(N).Y
Next
'Pass our delimiter
Args(1) = ","
'Call the script
WebBrowser1.document.InvokeScript("MakePoly",Args)

Code: [Select]
function MakePoly(points, delimiter){
//you need to unpack your points using the delimiter
//and create an array of GLatLng for API V2 or LatLng for API V3
//polyline building code goes here
}

Before I catch heat, I haven't used VBA for some time, so the example may contain errors .. specifically with the AutoCAD objects ... I can't believe how fast I forget these things ...

Incidently, you can also return the value of the function as a com object to your calling function, but there is no documentation on how to interact with it, although I have made some progress, it is hit and miss for the most part, although strings and markers return nicely and are relatively easy to interact with and manipulate.

Good luck!
Hi
Thanks Keith™ for answer
you wrote "UTM (i.e. longitude and latitude)" and I don't understand that UTM means xxxxxxE,xxxxxxxN or fil and lambda arcs in radian format? :?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: From Autocad tot google maps
« Reply #6 on: October 27, 2010, 03:07:41 PM »
UTM = Universal Transverse Mercator
Latitude and Longitude is the desired format (in decimal) ...

For example, if your polyline is from 0,0 to 12,3 to 12,6 the resultant polyline in google maps would start from
longitude 0 and latitude 0 then proceed to longitude 12 and latitude 3, then longitude 12 and latitude 6, so not something that is usable in a real world application.

You would need to draw your polylines in longitude/latitude coordinates or convert them to longitude/latitude before sending them to google maps.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Robert98

  • Guest
Re: From Autocad tot google maps
« Reply #7 on: October 27, 2010, 03:46:13 PM »
UTM = Universal Transverse Mercator
Latitude and Longitude is the desired format (in decimal) ...

For example, if your polyline is from 0,0 to 12,3 to 12,6 the resultant polyline in google maps would start from
longitude 0 and latitude 0 then proceed to longitude 12 and latitude 3, then longitude 12 and latitude 6, so not something that is usable in a real world application.

You would need to draw your polylines in longitude/latitude coordinates or convert them to longitude/latitude before sending them to google maps.
HI dear Keith™
I know that UTM is  Universal Transverse Mercator projection system and I know that at this system coordinates are in linear format in a plane like x and y in Cartesian system and its origin is start with 500000  and so on but longitude/latitude coordinates don't linear format , they are in Angle form (arcs in radian unit or curvilinear) and lies on the surface not plan , if it is possible use of negative x so system is UTM and it's coordinates are in line format and negative means that point lies at the west and if it is positive it lies at east semisphere . please tell me UTM coordinates (linear) format is must use or curvilinear (arcs) coordinates or both.
Please note that angular coordinates start from 0 to 90 degree toward north and 0 to -90 toward south and for other one one of them varies from 0 to 180  and 0 to -180 at other direction , so UTM members'  have strings longer than geodetic format  :ugly:
thanks you very much




« Last Edit: October 27, 2010, 03:57:08 PM by Robert98 »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: From Autocad tot google maps
« Reply #8 on: October 27, 2010, 05:33:28 PM »
I am not sure I understand the question ... but just in case ...

The coordinates must be in longitude and latitude format. For longitude any real number between -180 and 180 and latitude any real number between -90 and 90.

Also google maps only processes linear formatted polylines, no arcs or curves are allowed .. essentially anything that is acceptible in a shapefile is acceptible in a google map.

If you don't have the proper coordinates it will be nearly impossible to draw them correctly.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Robert98

  • Guest
Re: From Autocad tot google maps
« Reply #9 on: October 27, 2010, 05:50:10 PM »
I am not sure I understand the question ... but just in case ...

The coordinates must be in longitude and latitude format. For longitude any real number between -180 and 180 and latitude any real number between -90 and 90.

Also google maps only processes linear formatted polylines, no arcs or curves are allowed .. essentially anything that is acceptible in a shapefile is acceptible in a google map.

If you don't have the proper coordinates it will be nearly impossible to draw them correctly.
Hi dear Keith™
If they are between -180 and 180 and between -90 and 90 so they are in curvilinear coordinates and we must use fi and lambda in programs(angular format) so I check it tomorrow and I'll write you . :loco:
very thanks and Good Luck

Daniel Eiszele

  • Newt
  • Posts: 85
Re: From Autocad to google maps
« Reply #10 on: October 27, 2010, 06:10:32 PM »
@ Keith: I think the confusion has occurred because you said the coordinates for google were based on the Universal Transverse Mercator map projection and that the required format is decimal degrees of longitude and latitude.  The issue is that UTM is expressed in cartesian coordinates and would also require an explicit Zone so that you know where the origin was.

From my reading the google datum is the WGS84 ellipsoid, so decimal degrees of latitude and longitude is indeed the required input.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: From Autocad to google maps
« Reply #11 on: October 27, 2010, 06:56:14 PM »
@ Keith: I think the confusion has occurred because you said the coordinates for google were based on the Universal Transverse Mercator map projection and that the required format is decimal degrees of longitude and latitude.  The issue is that UTM is expressed in cartesian coordinates and would also require an explicit Zone so that you know where the origin was.

From my reading the google datum is the WGS84 ellipsoid, so decimal degrees of latitude and longitude is indeed the required input.

Indeed you are correct ... I am not a geo guy so I wouldn't know these things .. only what I read, so if that information is  incorrect, then that is all I have to go on ...

And please note that I mentioned several times the coordinate must be in longitude and latitude AND that it must be decimal ..

Also, there is no issue with utilizing any correction with the google maps as the projections are based on pure longitude and latitude .. if your drawing is done in pure longitude and latitude coordinates, then it is as simple as transferring those points to GLatLng or LatLng points as the case may be. It certainly isn't difficult, and I am amis as to why it has taken this many posts to get that point across. Oh well, I hope he got the answer he was looking for.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Robert98

  • Guest
Re: From Autocad to google maps
« Reply #12 on: October 28, 2010, 01:51:35 PM »
@ Keith: I think the confusion has occurred because you said the coordinates for google were based on the Universal Transverse Mercator map projection and that the required format is decimal degrees of longitude and latitude.  The issue is that UTM is expressed in Cartesian coordinates and would also require an explicit Zone so that you know where the origin was.

From my reading the google datum is the WGS84 ellipsoid, so decimal degrees of latitude and longitude is indeed the required input.

Indeed you are correct ... I am not a geo guy so I wouldn't know these things .. only what I read, so if that information is  incorrect, then that is all I have to go on ...

And please note that I mentioned several times the coordinate must be in longitude and latitude AND that it must be decimal ..

Also, there is no issue with utilizing any correction with the google maps as the projections are based on pure longitude and latitude .. if your drawing is done in pure longitude and latitude coordinates, then it is as simple as transferring those points to GLatLng or LatLng points as the case may be. It certainly isn't difficult, and I am amis as to why it has taken this many posts to get that point across. Oh well, I hope he got the answer he was looking for.
Hi dear Keith™
I check codes , it's Arguments are angles in decimal degree units in addition for northen semisphere is o to 90 and for southern semi sphere is 0 to -90 and 0 to 180 to eastern semisphere and 0 to -180 for western one .
Special thanks for your earnest  :angel:

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: From Autocad to google maps
« Reply #13 on: October 28, 2010, 01:55:36 PM »
Robert .. you are correct
 
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Robert98

  • Guest
Re: From Autocad to google maps
« Reply #14 on: October 28, 2010, 02:45:57 PM »
Robert .. you are correct
 
Thanks you