Codename one map component does not let me input longitude and lattidude (+ permissions) - codenameone

1st question:
I am trying to use the map component from codename one Theme. However, every time i put longitude and lattitude, it resets to 0.0. How can i change that from inside the theme?
2nd question, if possible: How do i show permissions, in order to enable using your own location? It is automatic when I use the map component, but not for other components.
When i try to use web view with google map, it does not let me put my own location.

You are using the old GUI builder which is no longer maintained. I would recommend switching to the new GUI builder or using handcoding. Notice you might be better off starting a new project as the new GUI builder is VERY different.
MapComponent is also deprecated in favor of native maps those are accessible from code and are far superior on the device... The Uber clone app was built using native maps.
Location prompts are automatic when you use the LocationManager API. You can enable them in the simulator to see how it feels on the device. You can then use the JavaScript interop to pass your location to embedded HTML.

Related

Geocoding with Mapbox

Background: I have just finished a course on Udemy called The Web Development Bootcamp. The main project for this course was to create a web app called Yelpcamp, which is essentially a campsite rating and discussion site. You can see the current working version of my app here: https://radiant-eyrie-76078.herokuapp.com/. It is built using node and express.
Problem: I would like to add a map to each campground showing where it is in the world. When a user adds a campground they will put in a location in a form and I need to take that location and convert it to latitude and longitude. I am using mapbox to add the map and I was able to get a simple map added to each campground. I now need to figure out how to take the input from the user and geocode it (convert it from a name to an exact location). Mapbox has a geocoding api, but I cannot figure out how to use it in this way. It seems that it can only be attached to the map directly.
Question: How can I take this location user input and geocode it so that it can be used by my mapbox map?
The Geocoding functionality of Mapbox does not require the presence of a map, and be called from the SDKs directly. That is, the input text of the geolocation can be user-provided or come from anywhere else (say, a DB, or a preexisting list of places).
Since your app is Node-based, you probably want the forwardGeocode function of the Geocode API in the JavaScript SDK.

How to stop MapContainer class in Codenameone from dragging/panning

I am using the MapContainer class to display a google map on android.
How can I stop the user from dragging/swiping the map to a new location ? ie. want the map to remain fixed at the coords I have set.
I have tried using MapContainer.setEnabled(false) but this only seems to work in the simulator and has no effect when deployed on a real android device.
TIA.
The panning is handled in the native map which handles its own events. Since those events happen on the Android UI thread Codename One can't intercept them without introducing a performance penalty.
You have two options:
Intercept the events in the native Android code
Fix the position after the fact
The second is much easier, just use a map listener to detect changes then pan the map using the API back to the original location. This might create undesirable UX though, in that case your only option is to use the native code.
You can do that by changing the cn1lib code and you can even contribute a feature back using a pull request. This should be relatively easy to implement in the native map as it should probably map to a setter/getter pair in the API e.g. setPanEnabled.

Map Component deprecated in Codename One

I'm facing some challenge in using maps, my map component is deprecated, is there something I should do to be able to use it and also would like to know the steps required to intergrate map keys to Codename One?
MapComponent is marked deprecated to discourage its use, but it should still work fine. The reason we discourage its use is because the Google Maps lib is better than it in almost every way. You should look at using that instead if possible.
There are instructions in the readme file on how to integrate your keys.
The Google maps library is updated with improvments please go throgh the below link.
new update n google map
you have added it from build hints as shown in as attached image.

What's the advised way to resume / pause a Codename One app with native implementation?

I am developping a mobile Codename One app (targeting Android for now, iOS then) that uses advanced camera features. Thus I need to use the native interface and implementation.
During the app lifecycle there is a need to release the camera (eg when the user switches from my app to another) which refers to onPause() in the Android world and to initialize the camera back again (eg when the user starts or goes back to my app) which referst to onCreate() in the ANdroid world.
So far when "pausing" and "resuming" my app I've used CN1 stop() and start() method from the main class where there I call a method from the native interface. But if you read the native GoogleMaps demo you'll see that they directly use onPause() and onResume() in the native implementation after adding a LifecycleListener during initialization.
Consequently which approach should be used for my next projects involving native interfaces ?
Any hint appreaciated!
Since this will probably apply to native implementations in other OS's I would just use stop()/start() and offer a method within my native implementation for pause/resume.
This will allow you to test that in the simulator, the more code you have on the Codename One side (as opposed to native) the easier it will be.

Create static JPG from Angular implementation of Google Maps

Here is my question, and afterwards I'll give some context.I'll try add as much info here to help.
Is it possible to render a JPG from a Angular implementation of Google Maps with dynamic waypoints?
Context:
We currently have an angular implementation of google maps that allows us to turn on and off waypoints from a GUI. Turning off a route, hides that from the map.
There are various settings that can be changed in the GUI that dictates where the waypoints will go and therefore the route.
The purpose or objective outcome is to be able to take a JPG of that map configuration and embed in email, attach, send to customer etc etc
UPDATE: I should note that we have considered building the static map through the API directly by appending waypoints to the URL, however we need to use our custom styled map overlay.
Any help or guidance would be most appreciated.
Thanks everyone!

Resources