Open map annotation on table row click? on Titanium - uitableview

I am new to Titanium and in the process of making my first iOS app using Titanium but I've hit a wall with a use case.
I am trying to open an annotation on the map by clicking on a particular row on a table view. I haven't had much success with this and was unable to find any help online. Is this impossible to do or am I just doing something wrong? The following is my code:
table.addEventListener('click', function (event) {
Ti.API.info("Index of row that is clicked: "+event.index);
globals.annos[event.index].fireEvent('click');
});
'table' is my TableView with a bunch of rows and global.annos[] is my array of annotations.
My objective is to open the annotation corresponding to the index of the table row that I have clicked.
The above code doesn't achieve anything. I thought firing the 'click' event of the annotation would open the annotation but clearly I was mistaken.
Could someone help me out here? Any help would be much appreciated.

If you are using Android the click event for annotations is not supported. A more cross platform approach is to fire the click event on the MapView itself.
But if you are using iOS, your click event is not set correctly, you have to define what part of the annotation your clicking, according to the documentation :
On iOS, if the user clicks on the pin or annotation, the clicksource is one of: pin, annotation, leftButton, rightButton, leftView, rightView, title, or subtitle. If the user deselects the annotation by clicking elsewhere in the map view, clicksource is null.
And you didnt pass an event object that defines the properties of the synthesized event. Try this inside your table event listener:
var event = {
source : table,
type : 'click',
clicksource : 'pin'
};
globals.annos[event.index].fireEvent('click', event);

SOLVED! Lack of reading the docs more thoroughly!
mapview.selectAnnotation(globals.annos[event.index]);
This opens the corresponding annotation.

Related

Xamarin Maps iOS Catch Tap on Annotation ( Marker )

i'm working on Xamarin Maps ( I'm using Forms with a CustomRenderer) on iOS. I'm putting some Pins on my Map, everything works fine until I decide to don't show any Baloon or View on my Pin when i Tap it. I just need to catch the event:
MKMapView.DidSelectAnnotationView
without display any title or subtitle. But the event is called only when i set a title and a subtitle. So, there is a way to put a pin that not display any baloon at Tap and just catch the Tap Event?
I tried to use
anView.CanShowCallout = false;
But nothing happen, the baloon is always showed. I'm using a ClusteringManager and this is the Source code: https://pastebin.com/A6tZAQzc .
Thanks a lot!
I was wrong, i was putting anView.CanShowCallout = false; Only on cluster and not on the single maker. My bad!

UITextField inside a custom UIView (InfoWindow) - The keyboard doesn't show up when I select the input

I'm making a custom InfoWindow for my markers. I followed the official Google Tutorial : Youtube link
Here is my .xib
User interaction is enabled...
My infoWindow show up above the marker as you can see on the screenshot :
But when I click on the pseudo input, the keyboard doesn't show up. Nothing happens!
I don't understand why it does that, because the user interaction is enabled...
The full View Tree :
From https://google-developers.appspot.com/maps/documentation/ios/marker?hl=ar-SA#info_windows
Note: The info window is rendered as an image each time it is displayed on the map. This means that any changes to its properties while it is active will not be immediately visible. The contents of the info window will be refreshed the next time that it is displayed.
Kind of lame, imho, especially if you have implemented the google maps js API, which provides complete control within any custom infoWindow.
I believe you will need to wire up an entirely separate overlay to make it interactive.

How do you use the showhide effect found in the Dart Widget Package

I am trying to use the ShowHide effect that comes with Kevin Moore's widget package here:
http://dart-lang.github.io/widget.dart/#showhide
Not sure how to use this. Anyone got an example I can look at ?
Basically all I want is for a dropdown to show with one of those effects if a certain event happens.
Your tips appreciated.
Thanks.
You need to add a listener for an event to an element in the DOM, and then use ShowHide.toggle(element, effect) to trigger an effect. Here is an example which listens for a click on a button, and toggles FadeEffect on an image each time it is pressed:
var button = query("#fadeButton")
..onClick.listen((event) {
ShowHide.toggle(query("#fadeImage"), effect: new FadeEffect());
});
If you wanted to fade in/out a dropdown when you click on a menu bar, then substitute "fadeButton" for the menu which listens for clicks, and "fadeImage" with the dropdown element.
Also, any other effect can be substituted for FadeEffect, such as DoorEffect, ScaleEffect, ShrinkEffect, etc.

Blackberry Maps closing oddly. Not Google maps

I'm having some trouble finding documentation on CLOSING a blackberry map.
My map opens, albeit with some odd marker behavior, but when you close the map it displays a clear screen.
The invoke code is quite simple, as the map request calls a new controller and within the constructor is this:
String document = "<location-document>... etc";
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));
I tried to add a close line
public boolean onClose() {
UiApplication.getUiApplication().popScreen(this);
return true;
}
but this is not being applied to the map itself, but the page the map opened into. That's logical, I guess.
Maybe I'm going about this all wrong. I don't know of how to open a map another way, or if there is a way to have the close button close the map AND the containing screen.
Any help is appreciated.
I solved this with a simple one line function that fixed this problem.
public void onExposed()
{
UiApplication.getUiApplication().popScreen(this);
}
Adding that to the map controller closes the map application when the user clicks the back button. Simple as that.

Open layer 3 + how make it behave like google map when mouse scroll

Google maps API show a message over the map when user scroll with mouse over the map.
The message advice the user must press control key while scroll with mouse over map.
This is a very nice solution to preserve normal page scroll with the mouse.
How can We do this in open layer 3+ API. Is thus possible? Please a need this behavior.
Thank you in advance.
Here the answers to your questions:
How to detect that the user is doing scroll on the map with the mouse and show an alert that you must press control key?
map.on('wheel', function(){
//write whatyou like and add it in popup window
});
How can you make it so the zoom on the map can only be done by pressing control in addition to scrolling with the mouse?
OpenLayers doesn't have this functionality but you can do it by changing ol.js as you want.
A helpful similar function can be found here
Also, you can do it with only (shift key) or (alt key)
map.on('wheel', function(evt) {
map.on('wheel', function(evt) {
wheelZoom(evt);
});
function wheelZoom(evt) {
if (ol.events.condition.shiftKeyOnly(evt) !== true) {
evt.browserEvent.preventDefault();
}
};

Resources