Jump to content

Google Maps UDF


 Share

Recommended Posts

Great opportunity to improve your skills, especially if you class yourself as a developer.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Hello!

I have modified this UDF for my project and for me it works as it has to work.
 

Functions:

_GUICtrlGoogleMap_GetLatLng() - slightly modified

_GUICtrlGoogleMap_Create() - added options: streetview, overview map, language (for directions, labels on map etc), weather unit

_GUICtrlGoogleMap_ViewLocation() - centers map to a new address

_GUICtrlGoogleMap_ViewCoordinates() - centers map to gps coordinates (for viewing real coordinates, not binded to the nearest address)

_GUICtrlGoogleMap_ZoomView()

_GUICtrlGoogleMap_GetMapZoom() - gets zoom level of displayed map

_GUICtrlGoogleMap_AddMarker()

_GUICtrlGoogleMap_HideAllMarkers()

_GUICtrlGoogleMap_ShowAllMarkers()

_GUICtrlGoogleMap_DeleteAllMarkers()

_GUICtrlGoogleMap_ViewAllMarkers()

_GUICtrlGoogleMap_SetMapType()

_GUICtrlGoogleMap_AddRoute() - visually adds route to map (with up to 4 waypoints, and draggable route)

_GUICtrlGoogleMap_GetRouteDetails() - gets directions of previously added route

_GUICtrlGoogleMap_GetPosition() - gets the position of marker (with draggable marker you can always have its actual position)

_GUICtrlGoogleMap_Weather() - enable or disable weather service with units defined in _GUICtrlGoogleMap_Create()

 

To add new route and get directions:

_GUICtrlGoogleMap_AddRoute($gmap, $start_location, $end_location, $travel_mode, $wp1, $wp2, $wp3, $wp4) ;travel_mode and waypoints are optional
Sleep(250) ;needed, otherwise can give empty directions
$directions = _GUICtrlGoogleMap_GetRouteDetails($gmap) ;contains directions steps, length of route and needed time for the route based on selected travel mode

Tested with my project under Windows XP (IE6,7,8) and Windows 7 x86/x64 (IE9,10,11).

I hope this by me modified and refreshed UDF will be handy for someone.

PS: Sorry if the code is not very clean... I'm still learning.

_Google Maps v2.au3

Edited by kescho
Link to comment
Share on other sites

Hello!

I have modified this UDF for my project and for me it works as it has to work.

 

To add new route and get directions:

_GUICtrlGoogleMap_AddRoute($gmap, $start_location, $end_location, $travel_mode, $wp1, $wp2, $wp3, $wp4) ;travel_mode and waypoints are optional
Sleep(250) ;needed, otherwise can give empty directions
$directions = _GUICtrlGoogleMap_GetRouteDetails($gmap) ;contains directions steps, length of route and needed time for the route based on selected travel mode

Tested with my project under Windows XP (IE6,7,8) and Windows 7 x86/x64 (IE9,10,11).

I hope this by me modified and refreshed UDF will be handy for someone.

PS: Sorry if the code is not very clean... I'm still learning.

Kescho, thank you so much, this sure will help :)

Thanks again for sharing this!

Link to comment
Share on other sites

I have updated the _Google Maps v2 UDF...

It had a small bug, the scale control was not showed on map even when enabled.

I found out that it was caused by the embedded webbrowser. The _IECreateEmbedded() embeds IE in version 7 even if newer version is installed.

More to read here: '?do=embed' frameborder='0' data-embedContent>>

Changes:

- to resolve the descibed bug I did not use any registry hack, only changed the compatibility to IE8+ - within the function _GUICtrlGoogleMap_Create()

- I changed a bit the function _GUICtrlGoogleMap_Create() - added zoom_style, changed scale parameter

- fixed some variables, constants etc...

It should work with IE8 and newer, I have tested it with IE11.

The updated UDF is attached below...

I also attach 2 ZIP files that contains a strip-down version of my project with needed UDFs (1x source and 1x compiled).

_Google Maps v2.au3

GMT - Google Maps Tool_source.zip

GMT - Google Maps Tool_compiled.zip

Link to comment
Share on other sites

@Kescho: impressive! thanks for sharing this!

3 questions for now:

1. Is it possible to draw a radius on the map?

Something like this: http://www.freemaptools.com/radius-around-point.htm

So user enter a coordinate (or location) and radius in metre, our script draw the radius/circle on the map.

2. Still about radius, currently it can count the driving distance between 2 coordinates, but can it count the radius distance?

So given 2 coordinates, and it count what is the RADIUS distance between those 2 coordinates.

3. Your GMT scripts can count distance between 2 coordinates, is it a driving/car distance?

Thanks again!

Link to comment
Share on other sites

1) I think it is possible to draw a lot of stuff on the map.

Everything is explained in the Google Maps API v3 Documentation: https://developers.google.com/maps/documentation/javascript/tutorial

Google Maps have many options for drawing objects, you just need to call the appropriate function with specific parameters.

2) all the calculations are done by functions in Javascript and results are passed to autoit variables and then showed in gui...

3) for my project the default calculations for distance between coordinates is by car/driving

- other modes are described in the function info for _GUICtrlGoogleMap_AddRoute():

$travel_mode        - 0 = Uses a travel mode of DRIVING
                                1 = Uses a travel mode of WALKING
                                2 = Uses a travel mode of BICYCLING

These are modes supported by google maps (+ one mode I'm not using: google.maps.TravelMode.TRANSIT - requests directions via public transit routes).

Edited by kescho
Link to comment
Share on other sites

There are two options: avoidHighways, avoidTolls which can be set to true/false.

The DirectionsRequest object literal contains the following fields:

{
  origin: LatLng | String,
  destination: LatLng | String,
  travelMode: TravelMode,
  transitOptions: TransitOptions,
  unitSystem: UnitSystem,
  durationInTraffic: Boolean,
  waypoints[]: DirectionsWaypoint,
  optimizeWaypoints: Boolean,
  provideRouteAlternatives: Boolean,
  avoidHighways: Boolean,
  avoidTolls: Boolean
  region: String
}

 

These fields are explained below:

  • origin (required) specifies the start location from which to calculate directions. This value may either be specified as a String (e.g. "Chicago, IL") or as a LatLng value.
  • destination (required) specifies the end location to which to calculate directions. This value may either be specified as a String (e.g. "Chicago, IL") or as a LatLng value.
  • travelMode (required) specifies what mode of transport to use when calculating directions. Valid values are specified in Travel Modes below.
  • transitOptions (optional) specifies values that apply only to requests where travelMode is google.maps.TravelMode.TRANSIT. Valid values are described in Transit Options, below.
  • unitSystem (optional) specifies what unit system to use when displaying results. Valid values are specified in Unit Systems below.

  • durationInTraffic (optional) specifies whether the DirectionsLeg result should include a duration that takes into account current traffic conditions. This feature is only available for Maps for Business customers. The time in current traffic will only be returned if traffic information is available in the requested area.

  • waypoints[] (optional) specifies an array of DirectionsWaypoints. Waypoints alter a route by routing it through the specified location(s). A waypoint is specified as an object literal with fields shown below:

    • location specifies the location of the waypoint, either as a LatLng or as a String which will be geocoded.
    • stopover is a boolean which indicates that the waypoint is a stop on the route, which has the effect of splitting the route into two routes.

    (For more information on waypoints, see Using Waypoints in Routes below.)

  • optimizeWaypoints (optional) specifies that the route using the supplied waypoints may be optimized to provide the shortest possible route. If true, the Directions service will return the reordered waypoints in an waypoint_order field.(For more information, see Using Waypoints in Routes below.)
  • provideRouteAlternatives (optional) when set to true specifies that the Directions service may provide more than one route alternative in the response. Note that providing route alternatives may increase the response time from the server.
  • avoidHighways (optional) when set to true indicates that the calculated route(s) should avoid major highways, if possible.
  • avoidTolls (optional) when set to true indicates that the calculated route(s) should avoid toll roads, if possible.
  • region (optional) specifies the region code, specified as a ccTLD ("top-level domain") two-character value. (For more information see Region Biasing below.)

 

 

I recommend you to read the Google Maps API.

Since I have read it, many new stuff was added, so I will read again too and then update my UDF with maybe new functions...

Edited by kescho
Link to comment
Share on other sites

  • 2 weeks later...

Thank's a lot, really fine.

I can run it but I cannot compile it, I get an error line 7188 ! (Windows XP sp3)

 

In Windows XP Mode I was able to reproduce this error only when I forgot to use the ini file.

When the ini file was in the same folder as the exe and had the same name as the exe file, then everything worked as it should, without any error.

Tested with IE6 -> no page loaded and with IE8 -> everything ok (WIndows XP Mode).

Link to comment
Share on other sites

How to print the map through AutoIT? Is there a ready to use function for printing?

Thank you :)

 

Sorry.. I'm not planning to add print function...

After reading some discussions about printing google maps, I'm not even sure if it is possible.

Link to comment
Share on other sites

I can run it but I cannot compile it, I get an error line 7188 ! (Windows XP sp3)

In Windows XP Mode I was able to reproduce this error only when I forgot to use the ini file.

When the ini file was in the same folder as the exe and had the same name as the exe file, then everything worked as it should, without any error.

Tested with IE6 -> no page loaded and with IE8 -> everything ok (WIndows XP Mode).

Ok, I have renamed "GMT - Google Maps Tool.ini" to "Google Maps Tool.ini" and I can compile "Google Maps Tool.au3" now.

Thank's for your help Kescho.

Link to comment
Share on other sites

@Tomy46: I see you're rather new to the forums ... so I want to pass a long a little tip I learned a couple of years ago:

Always read through the entire thread before you append a follow-up question ... especially for multipage threads.  9 times out of 10 your question will already be answered.  Doing otherwise unnecessarily adds to the length of the thread ... and often annoys the very people who know the answer to your question.

Edited by qwert
Link to comment
Share on other sites

Is it possible to click on the marker on the map and then it open a URL?

 

The marker can be clickable and you cant catch the click event with a function like in the example below:

google.maps.event.addListener(marker, 'click', function () {
    some commands...;
});

something like this:

- click on marker - listener sets a value to a variable

- with $GUI_EVENT_PRIMARYUP you start AdlibRegister which calls a function to read the value of the variable

- if the variable has correct value then open url, reset the javascript variable and AdlibUnRegister.

I have this for refreshing the position of the marker/get zoom level/refreshing directions in my example, so I think it could work also for catching marker click and opening an url.

Check the javascript listeners and functions in the UDF and the way they are called...

Link to comment
Share on other sites

It's commendable kescho that you have taken this UDF into your own, maybe you want to branch off and create your own thread?

I wish more users would take the innitative as you did. Thanks.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...