Android programmatically created MapView v2 is not displayed - android-mapview

I updated RawMapViewDemoActivity.java in the Android Google Maps v2 sample app to programmatically create a MapView but map is not displayed. I just get a blank screen.
I replaced
mMapView = (MapView) findViewById(R.id.map);
with
GoogleMapOptions options = new GoogleMapOptions();
options.camera(new CameraPosition(new LatLng(0, 0), 15, 0, 0));
mMapView = new MapView(this, options);
mMapView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
What am I doing wrong?

Have you forwarded all the livecycle methods to the new MapView?
mMapView.onCreate(savedInstanceState);
Take a look at the API Reference

Sorry - I fixed this a while ago, but forgot to post the answer.
It seems that a MapView must be placed in a layout container before it will be correctly displayed. The following snippet shows what I did to make the sample work.
LinearLayout linearLayout = new LinearLayout(this);
GoogleMapOptions options = new GoogleMapOptions();
options.camera(new CameraPosition(new LatLng(0, 0), 1, 0, 0));
mMapView = new MapView(this, options);
linearLayout.addView(mMapView);
setContentView(linearLayout);

Related

Apply MarkerOptions to a Kmllayer?

I have a KmlLayer loading successfully, though the pins are getting cut off due to canvas tiles, so it was suggested to turn "optimized: false" to the MarkerOptions.
So far everything I'm reading is showing how to set MarkerOptions when you're creating a new marker object, but I don't know how to apply MarkerOptions to the markers generated by the KML file.
How would I be able to set the MarkerOption of "optimized: false" to the code below? Or can I do this?
var map;
function initialize() {
var mapOptions = {
zoom: 3,
center: new google.maps.LatLng(39.157523,-100.25987),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),mapOptions);
georssLayer = new google.maps.KmlLayer('[KML FILE]', {preserveViewport:true});
georssLayer.setMap(map);
This appears to have been on Google's end. We were also experiencing this issue and it seems to have been resolved about an hour ago. Google will likely update this bug report:
https://code.google.com/p/gmaps-api-issues/issues/detail?id=10662

Admob issues on Xamarin iOS apps with Admob SDK version 6.12.0

I am currently using the Google AdMob Xamarin component (version 6.12.0 - see https://components.xamarin.com/view/googleadmob) to display DFP interstitials and banner ads (displayed at different points within a tableview) on an iOS app. When I am debugging in Visual Studio 2013 I get the following output:
<Google:HTML> You are currently using version 6.12.0 of the SDK, which doesn't
officially support iOS 8. Please consider updating your SDK to the most recent
sdk version, 6.12.2, to get iOS 8 support, including a fix for smart banner
rendering in landscape mode. The latest SDK can be downloaded from
http://goo.gl/iGzfsP. A full list of release notes is available at
https://developers.google.com/mobile-ads-sdk/docs/admob/ios/rel-notes.
According to the Xamarin component's page, 6.12.0 does actually support iOS 8. Should I ignore the warning that I am getting? If not, how do I go about using 6.12.2 when the newest version of the component is only 6.12.0? Is it OK to stay with 6.12.0 or will it cause issues?
I have noticed that the banner ads aren't really displaying in the correct location on iOS8, they are slightly to the right and down from where they should be. Is this because of the SDK or some other change in iOS8 regarding how cells are displayed?
Below is how I display the banner ad:
public void InitialiseBanner(AdMobView property)
{
_bannerViewDelegate = new AdMobBannerViewDelegate();
_bannerView = new DFPBannerView();
float x = (CurrentWidth/2) - (AdvertWidth/2);
_bannerView.RootViewController = this;
_bannerView.BackgroundColor = UIColor.White;
_bannerView.Delegate = _bannerViewDelegate;
_bannerView.Frame = new RectangleF(x, 5, AdvertWidth, 50);
View.Frame = new RectangleF(0, 0, CurrentWidth, 50);
View.AddSubview(_bannerView);
_bannerView.AdUnitID = "/**UNITIDREMOVED**/" + property.AdAlias;
GADRequest request = GADRequest.Request;
.
.
.
_bannerView.LoadRequest(request);
View.BringSubviewToFront(_bannerView);
if (DeviceHelper.IsIos8OrGreater && RespondsToSelector(new Selector("separatorInset")))
{
_bannerView.LayoutMargins = UIEdgeInsets.Zero;
}
}
As for a normal banner, try loading your AdView Like this:
(This is my working example)
As a class level declaration, type this:
GADBannerView adView;
bool viewOnScreen = false;
// Get you own AdmobId from: http://www.google.com/ads/admob/
const string AdmobId = "<your admob id>";
Then in your viewDidLoad you can specify position of your banner and load it:
adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, UIScreen.MainScreen.Bounds.Height-100)) {
AdUnitID = AdmobId,
RootViewController = this
};
adView.DidReceiveAd += (sender, args) => {
if (!viewOnScreen) View.AddSubview (adView);
viewOnScreen = true;
};
adView.LoadRequest (GADRequest.Request);
I get the same error as well, but it doesn't actually matter. I also thought first that this was the issue but my setup was a bit wrong, i think that is the same for your code. In my example i just added my AdView to the MainView, but using custom cells you should be able to implement it in your UITable View. Also, have a look at the example provided in the components section. As for displaying DFP interstitials: There has to be something wrong with the setup as well, but i can't see it in the code you provided.

How to create user notification message similar to JGrowl

I started to work to user notification message similar to JGrowl for JavaFX.
public void newMessage()
{
final Stage newConnDialog = new Stage();
newConnDialog.initStyle(StageStyle.UNDECORATED);
newConnDialog.initModality(Modality.WINDOW_MODAL);
// Set pisition
newConnDialog.setX(1050); //secondStage.setX(primaryStage.getX() + 250);
newConnDialog.setY(150);
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(5);
grid.setVgap(5);
grid.setPadding(new Insets(20, 20, 20, 20));
// text
Text productName = new Text("Test");
productName.setFont(Font.font("Verdana", 12));
grid.add(productName, 0, 2);
// Configure dialog size and background color
Scene aboutDialogScene = new Scene(grid, 200, 100, Color.WHITESMOKE);
newConnDialog.setScene(aboutDialogScene);
newConnDialog.show();
}
I have a basic knowledge about JavaFX. Can you give me some basic advice what will be the best way to implement this component. For example do I need to create new Stage or I can use other component as stage. How I can hide the component after 10 seconds activity and etc. Any advice will be highly appreciated.
P.S.
I found this example for JavaFX 1.3 Maybe it can be rewritten for JavaFX 2.2?
This is one possible solution by using the Enzo library:
// Create a custom Notification without icon
Notification info = new Notification("Title", "Info-Message");
// Show the custom notification
Notifier.INSTANCE.notify(info);
// Show a predefined Warning notification
Notifier.INSTANCE.notifyWarning("This is a warning");
Source
You can use the ControlsFx library to create notifications
http://docs.controlsfx.org/org/controlsfx/control/NotificationPane.html
you can try JFXToast see github
that can help you doing this work
this is an class for empelement toast in javafx

Generate Screenshot From WebBrowser Control

I grabbed some code from the link below to generate a screenshot from a web browser control:
http://pietschsoft.com/post/2008/07/C-Generate-WebPage-Thumbmail-Screenshot-Image.aspx
Then, I modified to be an extension method like so:
public static Bitmap GetScreenshot(this WebBrowser webBrowser)
{
// Load the webpage into a WebBrowser control
using (WebBrowser wb = new WebBrowser())
{
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(webBrowser.Url);
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
// Set the size of the WebBrowser control
wb.Width = wb.Document.Body.ScrollRectangle.Width;
wb.Height = wb.Document.Body.ScrollRectangle.Height;
// Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
return bitmap;
}
}
It works great for most web pages, but I am trying to use it for a SharePoint site and the image is coming out as 250x250 every time. :-s
Any geniuses here that can give me a solution?
Thanks in advance
Well, the reason for this seems to be that my new WebBrowser (wb) is uninitialized even after I call Navigate(). The Url property shows as null. This is weird. Does it mean I cannot create a WebBrowser in code and never display it? It would be a shame to have to display the thing. :-(
You can check that question taking-screenshot-of-a-webpage-programmatically.
It is based on this webpage_thumbnailer which uses Web Browser control.
For one, the DrawToBitmap class does not exist under the webbrowser control. I suggest using CopyFromScreen. Here is a code snippet:
Bitmap b = new Bitmap(wb.ClientSize.Width, webBrowser1.ClientSize.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(this.PointToScreen(wb.Location), new Point(0, 0), wb.ClientSize);
//The bitmap is ready. Do whatever you please with it!
b.Save(#"c:\screenshot.jpg", ImageFormat.Jpeg);
MessageBox.Show("Screen Shot Saved!");

Manually instantiating a view... black screen

I was trying out doing a manual instantiation of a view and all I get is a black screen.
Here's the core of my FinishedLoading
currentController = new ChoicesScreen(this.window.Handle);
window.AddSubview (currentController.View);
window.MakeKeyAndVisible();
note: CurrentController is a protected UIViewController currentController
ChoicesScreen is defined in IB, has the proper outlets, actions, etc. in other words its a valid view.
I tried the default constructor for ChoicesScreen and got the same thing. Obviously I'm missing something in how to get my own screen up.
Driss,
You need to set the frame for the new view, to define where it'll show in the view:
currentController = new ChoicesScreen(this.window.Handle);
currentController.View.Frame = new System.Drawing.RectangleF(0, 0, 320, 480);
window.AddSubview (currentController.View);
window.MakeKeyAndVisible();

Resources