How to explicitly set marker IDs - xamarin.android

I want to set IDs of the markers that I show on the map. For instance, when I show four markers, I want to give them IDs 10, 20, 30 and 40 explicitly. Now they get m0, m1, m2 and m3. By the way, I need this so that when I click on the Info Window of any of these markers, I get the ID and know which marker's Info Window is clicked and that way I can use that ID (e.g. show it in a toast message for now).
Thanks.
Ahmed

You can not set the marker-IDs on your own. But the method addMarker returns the marker with its ID set.
When later on the marker is clicked, the ID will be the same.
So you need to keep track of the IDs and the corresponding objects the markers stand for on your own e.g. by maintaining a map of marker IDs and objects, where you add a new item after each call of addMarker.

Related

Google maps markers Filter [duplicate]

This question already has an answer here:
maps markers with input sliders
(1 answer)
Closed 4 years ago.
i have a huge list of stores with addresses (longitude and latitude and codeclient ....). For each stores, a marker appears on the Google Map on the page.
my problem is, users must be able to filter these markers depending on one thing: CodeClient. So to be more specific. If the user sets the CodeClient in the input slider it is supposed to only show the client (the owner of the CodeClient who we put in the slider) Like this ; CodeClient = 12345 , so when we put the number 12345 in the the input slider , and click on the button it should display only the marker of this client , i mean the markers who refer to the place of this client.
the problem is solved by xomena , this is the path for the solution
Filter Google maps markers with input sliders based on one variable
Seems like you are partially asking about setting marker visibility? As touched on in this Stack post (among others)
Google Maps API Marker Visibility
Most likely, marker.setVisible(true/false) is the way to go.
And then basically you would be doing that in the change event handler for the slider input.
One idea is loop over the markers array and toggle it invisible while setting the marker matching selected coce-client visible.
Another idea is to make it a "marker dictionary" where the keys are the code client value, i.e.:
markers = {
12345: SomeMarkerInstance,
67890: SomeOtherMarkerInstance,
// ... etc
}
selectedMarker = '12345'
and in that way you could quickly just toggle off visibility on the current selected marker while toggling on the newly selected marker. The rest of the markers would be by default not visible.
I.e. (pseudo codey)
function someEventHandler (event) {
markers[selectedMarker].setVisible(false)
markers[selectedCodeClientValue].setVisible(true)
// and perhaps other stuff, e.g. recenter the map, etc
}
You are setting a title to your markers with this CodeClient and you are pushing your markers in an array. So what's the big issue here? Simply loop through your array and set the marker visibility based on the title (CodeClient).
for (var i=0; i<markerArray.length; i++) {
if (markerArray[i].title == '12345') {
markerArray[i].setMap(map);
} else {
markerArray[i].setMap(null);
}
}

Can we add multiple values on balloon marker with image in ios-charts?

I am using ios-charts and i added one value to balloon marker,
now i wish to add two values in two line in balloon marker and also wants to add two dots before that two values, i have implemented it in objective c.
I want to change balloon marker font color as well
So is it possible to implement in iOS charts ?
I would say it's definitely possible, but how easily you can do it is what you need to think about.
Balloon marker is just a example of how to use ChartMakrer. You can of course sub class ChartMarker and make your own.
I would consider render all your values and dots into one image, and assign it to ChartMarker's image property.

Remove only restaurants from MKMapView

I'd like my MKMapView to show points of interest except restaurants. Is this possible, and if yes, how can I set this up?
I did see the below in the Documentation but is it really all or nothing?
#property (nonatomic) BOOL showsPointsOfInterest;
When this property is set to YES, the map displays icons and labels for restaurants, schools, and other relevant points of interest. The default value of this property is YES.
For example, in the below, I want the gas station to show but not the restaurant.
With IOS 13 you have the option to filter: here a example to show no items on the map
localMap.pointOfInterestFilter = .some(MKPointOfInterestFilter(including: []))
For example you can filter airports out of the map...
localMap.pointOfInterestFilter = .some(MKPointOfInterestFilter(including: [MKPointOfInterestCategory.airport]))
It's not possible to control the specific type of points that are plotted. Apple could add/remove/change the specific types it displays in any future update of Map Kit. As you mentioned, your only course of action is setting showsPointsOfInterest.
You could use a third-party place database from Foursquare or Facebook to get similar points of interest and plot them on your map, however there is no guarantee that the results would match the ones Apple would otherwise show.
Another option in iOS 13 is to include or exclude certain points of interest:
// Includes airports
localMap.pointOfInterestFilter?.includes(MKPointOfInterestCategory.airport)
// Excludes laundry/laundromats
localMap.pointOfInterestFilter?.excludes(MKPointOfInterestCategory.laundry)

Delphi, TTreeView: how to get the screen coordinates of the given node and its icon?

Please help me to get the screen coordinates of the state icon rectangle of the given TTreeNode in a TreeView (I mean the icons specified in the TTreeView.StateImages property).
There is a TTreeView.GetHitTestInfoAt(X, Y: integer): : THitTests function, but that is not quite what I'm looking for; it says whether the given coordinates correspond to the label, or to the icon, or to the state icon of the item, but I need to know what part of the icon was clicked.
(The reason is that I want to implement the TreeView nodes with two checkboxes for each item, and I use StateImages to simulate the checkboxes (one state is a checked item, the other state is an unchecked item). As I understand, to know which one of the checkboxes is clicked I need to compare the cursor coordinates with the state icon coordinates. How can I get them?)
You can send the control a tvm_GetItemRect message which will tell you the client coordinates of the item's bounding box. Use that and what you know of the relative positions of the label text and the icons to determine where the mouse was clicked in the icon.
Instead of GetHitTestInfoAt, you might prefer to send a tvm_HitTest message instead since it will give you the hit-test information and an item handle at once; a handle is what tvm_GetItemRect requires.
You don't need the screen coordinates since all the coordinates involved so far are client coordinates, but you can call ClientToScreen if you really want screen coordinates.

Making google maps move on a path

I've got a website vith a view of a (long) street, with markers appearing all along it that have different information on them about that location.
What I'm trying to do is create a button so when you press it, it starts at the bottom of the street and slowly moves the map along the street, opening each pop-up as you go then closing it when the next one opens.
The markers are all generated using a php loop linked to a database of information and I'm using InfoBubble to create the pop-ups.
You can use the google function bounds.extend and fitBounds: Google Map API v3 — set bounds and center and add some of your markers to the array and wait a bit and add new markers to the array and rinse and repeat. You can use a javascript timer to wait. Or you can save your path and use fitbounds only on that marker.
Edit: When you have the next bounds with getBounds you can calculate delta x and delta y, e.g. x2-x1 and y2-y1 from 2 points of the start bound and the target bound.

Resources