QTP with Google Map - google-maps

I am working on Web Application that uses Google map. I need to verify balloons present on map. After some Google, i came across this link Automating Google Earth .But this isn't helped lot.Does anybody has idea to work with maps in QTP?
I want to test this in IE8. When clicked on balloons, description is displayed.Need to test this description.Image for info
Any help ?

This seems to be browser specific (and I'm sure it will change with changes in Google Maps) but I see in firefox that when there's a balloon then area and map elements are added to the DOM. You can create a WebElement with this html tag and see if it exists.
I don't really understand what problem you're facing. I can easily learn the DIV element which hosts a Wikipedia bubble and the elements under it with QTP.

you can try html dom if it is java application by using getElementById method from html dom ,
open firebug check the element of the pointer and get the id from it. use the id in getElementById method.
or
check this
Sub PostGPSLocation
Call Mobile.SetCurrent("Nexus 7")
' Obtain location data
Longt = Mobile.Device.GPS.Location.Longitude
Lat = Mobile.Device.GPS.Location.Latitude
' Output the location data
Call Log.Message("The device location is:")
Call Log.Message("Longitude: "&Longt)
Call Log.Message("Latitude: "&Lat)
Call Log.Message("Altitude: "&Mobile.Device.GPS.Location.Altitude)
Call Log.Message("Accuracy: "&Mobile.Device.GPS.Location.Accuracy)
' Open Google Maps in the browser and pass the coordinates as URL parameters
Call Browsers.Item(Browsers.btIExplorer).Run("http://maps.google.com/maps?q=loc:"&Lat&","&Longt)
End Sub

Related

How to get the first tile overlay google maps js

I'm using Google Maps SDK to show a map on my site. In addition, I'm showing some custom pins using tiles overlays -> https://developers.google.com/maps/documentation/android-sdk/tileoverlay .
I'm inserting an overlay like this:
const tileAdaptor = new SomeAdaptor();
map.overlayMapTypes.insertAt(0, tileAdaptor);
And now, from other part of my code, I want to access that same instance. I was doing it like this:
window.map.overlayMapTypes.je[0];
But, surprisingly, the .je attribute has been renamed! I do not know if that's because it's an internal API or something like that. Now it has been renamed to .td.
So, my question is, is there a way to get that first overlay without using internal APIs?
Don't use undocumented properties, they can (and will) change with any new release of the API.
You need the overlayMapTypes property, which is a MVCArray, which has a getArray method
window.map.overlayMapTypes.getArray[0]

Google map zoom parameter in url not working

Why doesn't google map z (zoom) parameter work inside the url?
I' ve searched over so I got few solutions for sending zoom parameter in google map url but based on the old posts (stackoverflow) which deal with the zoom level within the url it seems that this functionalities do not work anymore.
I've used the following z parameter but it's not working:
http://maps.google.com/?q=38.6531004,-90.243462&z=12
Below is the link where they have mentioned z parameter for zoom level
link
For those who do not want to read,
this works (z range:[1-20]):
https://maps.google.com/?q=38.6531004,-90.243462&ll=38.6531004,-90.243462&z=3
There is no documentation that covers this problem. However, there are few hacks.
The link that you have provided,
URL (stackoverflow):What parameters should I use in a Google Maps URL to go to a lat-lon?
Will not help you with getting the desired google maps zoom level inside a url
The following examples which have been working for quite a while DO NOT WORK anymore (they work but without getting the desired zoom level)
Examples:
http://maps.google.com/?q=38.6531004,-90.243462&z=3
http://maps.google.com/?q=38.6531004,-90.243462&zoom=3
http://maps.google.com/maps?q=Scottish+Rite+Hamilton+ON&loc:43.25911+-79.879494&z=15
Instead, you can get the zoom level easily by trying the following examples:
https://www.google.com/maps/#38.6531004,-90.243462,9z
https://maps.google.com/?ll=40.7060471,-74.0088901&z=3
(Note: after clicking on google maps you will get a gray marker which appears and quickly disappears)
However the above URL's will not give you a static pinpoint for the specified lat&long.
There is a "hack" on how to get a fixed pinpoint (red marker pin) and that is by giving the q attribute (represents the search query) and the II attribute(latitude and longitude of the map centre point) along with the z (zoom attribute)
Example (with the OP coordinates):
https://maps.google.com/?q=38.6531004,-90.243462&ll=38.6531004,-90.243462&z=3
If you want to change the zoom level just change the value of 'z'.
After searching the web I found that only this website:
https://moz.com/blog/new-google-maps-url-parameters
deals with google maps parameters/attributes/arguments, where things actually still work. If anyone want's more functionalities within the url, then this is the site to check.
Zoom intervals explained (https://developers.google.com/maps/documentation/static-maps/intro#Zoomlevels):
The following list shows the approximate level of detail you can
expect to see at each zoom level:
1: World
5: Landmass/continent
10: City
15: Streets
20: Buildings
This works as of 5 Aug 2018
http://www.google.com/maps/place/<lat>,<lng>/#<lat>,<lng>,<zoom>z
For example
http://www.google.com/maps/place/49.46800006494457,17.11514008755796/#49.46800006494457,17.11514008755796,7z
As of 04/2020 ...."because google is always changing and evolving"
In complement to Eugen Sunic comments above, and an alternative update to the Solution.
When Logged in to google and getting map data from the google generator, it is not the same as copying the URL from the browser window (which my may be manipulated to load different zooms trough the various alterations, html, Css and script tricks).
But in the below, keep in mind that Your address info may need to be part of the google array of database, eg you have some address map info linked to your account, images, business name, etc. or not... maybe just typed in for a quick map search with a pin-point... the later I don't know.
Also the below is not some Google API pay per 1k clicks thing, which is more geared to the commercial development end of google tracking heat maps, etc. So if you just need a simple solution and certain zoom and marker to work..then you might try the below.
When logged in too your Google account (maybe not) and showing your location marker on the map screen...
Choose the zoom detail of the map you want to appear in your web page. eg Whole US, State views, City, Street (by clicking the + or - zoom feature).
Then go to the hamburger menu to the left, and look down the list for "Share or Embed Map" and the popup window should load the same zoom level of the map! Do not try to change the zoom in the popup window feature, it wont work to change the link code but will change the pop up windows zoom of the map. In short, the embedded link code is preset and will not change in the popup.
Above this popup window of the map there will be two options at the top (Share and Embed) button/link selections.
Click on the Embed link/button and it should generate the code for the zoom you previously chose.
Lastly, copy the code, paste it into your web page and TEST!
As far as I can tell, There is no altering this code as the others suggested above, changing(z=3, 9z, etc) as the code is entirely different. But it will allow you to get the zoom you need "if the google code generator or procedure does not change".
But the zoom level was altered and good enough for me when I figured the process out. Changing it to other zooms is another can of code.

Embed mymaps on website with possibility to see current position on mobile

I want to embed "my maps" to my website using iframe, but I want to let my clients to open that map in a new window and see their location on it.
If I open my map in edit mode on my phone: www.google.com/maps/d/edit?mid=*** I see my position, if I change the mode to "view" it stops tracking my location.
Is there a way to open the big map and to see the current position? It's very useful... Maybe there is another way to embed it...
Based on the documentation
url: https://developers.google.com/maps/documentation/staticmaps/intro?hl=en
it seems that it is not possible to get the current location (position of the client) using the parameters which go along with the url. This means that you can not use iframe and embed google maps inside it to get your current position.
However, you can still use geolocation and program it to get the user current position on the map,
url (code included in the link): https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
Bare in mind that the google map API will always ask you the permission to access data in order to locate you.

How can I click on a google map with capybara to create a marker

I have a google map on a page. User's can click on this map and it will drop a marker at that point. How can I simulate this in Capybara? It doesn't matter where they click as long as it's somewhere on the map.
I think you can use ActionBuilder if you use Selenium driver. It will be something like:
within_frame(locator_of_frame_with_map) do
map = find(locator_of_map).native
page.driver.browser.action.move_to(map, x, y).click.perform
end
Code above is a draft. Obviously I can't provide working code without a demo.
Capybara itself doesn't have a cross-driver API for clicking at specific coordinates.
with webkit driver in Capybara, I've used this:
javascript_to_trigger_click = <<-JS
$('#map > div > div:nth-child(1) > div:nth-child(4) > div:nth-child(1)').click();
JS
page.evaluate_script(javascript_to_trigger_click)
where #map is my element containing the google map.
Side note but I've lost so much time on this, be sure to enable whichever url capybara thread is running its test server into google console for your app. (you can see the url by setting config.debug = true for capybara)

Do i need use google maps api only to embed litle map with route calculator/display for only one destination?

Well i want to upgrade contact page with dynamic map showing location and give oportunity to calculate route for comapny headquatters. Id it necessery for such simple task use Google api? i mean here generating akey etc? Fo i have any other alternatives to google maps?
There's really no reason to mess with the API at all unless you need to customize the appearance or behavior of gmaps. Why not just use an iframe with a url of:
http://maps.google.com/?q=[you-url-encoded-address-here]
or better yet, set up a textbox and a 'get directions' button to redirect that frame to:
http://maps.google.com/maps?saddr=[their-address]&daddr=[your-address]
edit: this works well in modal dialog if you don't want the google logo sticking out like a sore thumb in your pageflow
You could probably embed directly with a specific URL that will configure it to have the destination you want.
By the way, well written answers are much more likely to receive useful responses here.
You could consider http://www.openlayers.org/ as an alternative to google maps.
In fact open layers can be used to add a Google map, or an OpenStreetMap map or a Bing map, etc.