Print map image/Google street view (Using Google Static Map API) - api

Problem Statement: A user will enter a property address or Lat/long based on that we need an image of Google Maps to print on a document for the end user so the user better understands the property location and nearby properties likewise, parks, lakes, etc. Please see the below criteria,
Print a Google Map image on the flyer/document.
Size should be 2000*1051
Image should display the Parcel boundaries.
Using Google Static map API.
We highly appreciate your advice, and the possible solution to achieve keep in mind the above requirement.
Technology: PHP Laravel Framework and Maps API
Please let us know if you need any additional information.

You don't give us in which language you try to do that, but I think it can help you :
var page = require('webpage').create();
page.open('http://www.google.com', function() {
page.viewportSize = {width: 2000, height: 1051};
page.render('screenshot.png');
phantom.exit();
});
How to take the screenshot of part of Google Maps use JavaScript

Related

Scrape dynamic websites using dart in flutter app

I have a website that generates a list of items using some javascript and I am trying to scrape it inside my flutter app using beautiful soap package for dart. The thing is that I am unable to scrape the dynamic data generated by the java script. I want to implement a solution that allows me to grab the source code of the website after it fully loads inside the app. A hidden webview inside the app would be perfect but what is blocking me is that how to get the data after the webview loads. This is my main concern. Code examples would be appreciated. Also better practices are welcomed.
What I have came to realize is that scraping dynamic websites that contain some javascript or a website that you want to click in it using a certain script to scrape it properly is not possible over flutter mobile. What you should do is to move the scraping to the cloud by creating your own api then using this api to return the response to your app. This will make scraping easier since you will not have to update your app for every error you find in your scripts. Also imagine that the website that you target updates itself every week, then you will have to update your app every week and wait for approval from all the stores you are subscribed to. A simple example would be using cloud functions from firebase in combination with javascript by utilizing the puppeteer package. A simple video tutorial is here: Tutorial over youtube
After lots of research I did indeed find a way.
Basically loading a hidden webview and scraping the data off of it, then showing it on screen. Here's how..
Spinning a webview in the UI
The Visibility widget and width/height properties will make sure the webview is impossible to be seen by the user. I suggest showing a loading screen until the data is scraped.
Visibility(
visible: false,
maintainState: true,
child: Container(
height: 1,
width: 1,
child: WebViewPlus(
onWebViewCreated: (controller) async {
log.e("onWebViewCreated");
await model.onWebViewCreated(controller);
},
onPageFinished: (url) async {
log.e("onPageFinished");
await model.onPageFinished(url);
},
javascriptMode: JavascriptMode.unrestricted,
),
),
),
The actual scraping
onWebViewCreated(controller) async {
this.webViewController = controller;
// Load the URL
await controller.loadUrl("<Your Website URL Here>",headers:_apiService.getAuthHeader());
// Get the HTML of the webpage as a JSON object
String docu = await webViewController?.webViewController.evaluateJavascript('document.documentElement.innerHTML') as String;
// Convert from JSON to String
var jsonString = json.decode(docu);
// Parse the String to a HTML DOM to actually access the elements
var dom = parse(jsonString);
// Some logic I needed in my application by scraping
for (var child in dom.getElementById("autodl-log-tbody")!.children) {
feed.add(child.text);
}
}
Pro Tip : If you think the webpage might need a bit more time to load, you can stall the execution of the function by using await Future.delayed(Duration(Seconds:5)); before the line of code where you load the URL in the onWebViewCreated() function.

How see analytics about branch links created using mobile SDK

I am creating dynamic branch links using Android SDK
https://github.com/BranchMetrics/android-branch-deep-linking#creating-a-deep-link
These are then shared to social media
How do I track things like click events, installs etc as I do not believe they show up in the dashboard quick links view? https://dashboard.branch.io/quick-links
Is there a HTTP API I can use to interrogate all links I may have dynamically created that are part of the same campaign?
Alex from Branch.io here:
You are correct that SDK-generated links do not show up in the Quick Links view on the dashboard. Most SDK-created links are 'disposable' (in that they get used once and then regenerated the next time), so showing every link there individually would quickly overwhelm the UI. It is possible to override this on a link-by-link basis with the type parameter, as detailed here.
However, you can access the numbers in aggregate, segmented by campaign value, which I believe is what you want anyway. This is not currently available through the API, but you can see these statistics through the Sources report on the dashboard: https://dashboard.branch.io/sources
you must include a "type": 2 in your branch params
https://help.branch.io/developers-hub/docs/deep-linking-api
const branchConfig = {
"branch_key": environment.branchio.key_live,
"type": 2,
"data": {
"$marketing_title": (params.job_name ? params.job_name : ""),
}
};

Magnific Popup - Google Maps Embed API must be used in an iframe

Magnific pop up for Google Maps not working on Chrome mobile. When triggered I get "Google Maps Embed API must be used in an iframe".
It works perfectly with the Google Maps URL given in the Magnific example but not when I use my own, I'm not sure if Google have changed their URL structure since but it looks like the new "embeded" URL is causing the problem.
Here's an example of the kind of URL I'm using: https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2382.9841570555454!2d-6.227123684388949!3d53.32563697997466!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x48670ec57aa7b09d%3A0x7965235d57af13f!2sClayton+Hotel+Ballsbridge!5e0!3m2!1sen!2sie!4v1453039698107
Is there a way I can change this URL to more like the working URL structure given in the example?: https://maps.google.com/maps?q=221B+Baker+Street,+London,+United+Kingdom&hl=en&t=v&hnear=221B+Baker+St,+London+NW1+6XE,+United+Kingdom
Been wracking my brains with this one....any help would be greatly appreciated!
Thanks!
David
I noticed this too. It's because Magnific Popup uses "maps.google." whereas Google now uses "www.google.". I had this which didn't work
https://www.google.co.uk/maps/place/Leathermarket+Gardens
and I changed it to
https://maps.google.com/maps?q=Leathermarket+Gardens
Which now works.
Hope that helps a little.
Google maps should be embedded in iframe in Magnific pop plugin
Sample:
View map
Because the right solution isn't listed here. The only thing you have to do is removing this attribute: disableOn: 700.
Keep only the code below:
$('.popup-gmaps').magnificPopup({
disableOn: 700,
type: 'iframe',
mainClass: 'mp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
Then it will works again.
PS: If you want to keep the new Google URL address form, you should change code inside jquery.magnific-popup.js library from:
gmaps: {
index: '//maps.google.',
src: '%id%&output=embed'
}
to:
gmaps: {
index: 'google.com/maps/',
src: '%id%'
}

Modifying photosphere on website thing

What i am trying to do is to use a photosphere on my website so that it shows up on full screen as a website cover page. The problem is the the code to embed a photosphere in a webpage given here by google
https://developers.google.com/photo-sphere/web/
lets only the photosphere size to be hardcoded as
displaysize="600,400"
what ever the values but its still hardcoded. What i want is that it gets adjusted to the screen of the user and gets displayed in the whole browser window. Any one got an idea how to pull it off? I didn't find any stuff about 'photosphere on web' other than the google link i gave above.
Indeed the API is currently designed to take static values. I think it's a good point that users might want to set the dimensions to 100% and let it resize dynamically.
I put it on the TODO list and will try to get to it shortly.
In the meantime, one work around is the following: After the viewer loads you will find an iframe on the page which contains it. You can change it's dimensions dynamically to your liking and the viewer should adapt.
The API provided by Google wraps the whole photosphere in layers of iFrames.
You can use the API to request a certain photosphere but only use the response to parse it for the values you need. Then you create your own request and the result can be shown fullscreen.
An example link is this
I created this link dynamically from the JSON response from the elements
media$group media$content 0 url
Hope it helps.
Can't you take the raw image and just use webgl to project it on the inside of a sphere?

Google Maps custom marker - can the iframe accept one like the static maps?

I was reading the static maps API, and it says you can include a custom marker in the GET params. You simply link to an image file.
I now have a second Google Map within an iframe, and was wondering if you can attach custom markers via the GET params to it? Here is the src attribute of the iframe currently.
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=111+Fake+Street+Noosaville+Queensland+Australia&ie=UTF8&output=embed
I can't seem to find the documentation on how to do this, if possible.
Is this possible?
As far as I know you cannot add custom marker icons on maps.google.com, but you should be able to add a marker with a custom label.
You may also be interested in checking out the following reference, which describes all the known parameters that can be passed to maps.google.com:
Mapki: Google Map Parameters
While this is not an official API, I think it is fair to say that these should be quite reliable, since they are the same parameters used for the permanent links in Google Maps.
On the other hand, you may want to consider using the Google Maps API instead. You will get all the capabilities you had with the Static Maps API (and more), and it will look pretty much the same as the iframe you are using right now.