To remove a normal marker from a map, I understand you simply call marker.setMap(null), but when implementing the Google Maps directions services, it automatically adds markers A and B onto the map ( calculating directions from point A to point B ). I do not have control over these markers, so I cannot remove them in the normal way. So how can I remove these markers (I have custom markers on the map instead)?
Set the suppressMarkers option to true when creating your DirectionsRenderer object and then the markers won't show up. You could also change the style or icon of the markers. See the API spec for DirectionsRendererOptions for other properties you can set.
...
directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true});
...
EDIT: It looks like the API changed a little bit since my original answer almost 6 years ago, so the answer from #joni-jones is now the correct way. I tweaked my example above to reflect that.
I had a similar problem. The previous solution did not help me. But I tried this:
var directionsDisplay = new google.maps.DirectionsRenderer({suppressMarkers: true}); And it's work.
Related
In order to refresh a part of the grid, i.e., when font or alignment changes, I was using the following approach:
wxRect rect1=CellToRect(TopLeft);
wxRect rect2=CellToRect(BottomRight);
wxRect r(rect1.GetTopLeft(), rect2.GetBottomRight());
RefreshRect(r);
This was refreshing only a part of the intended block and was not working correctly.
From the suggestions of intellisense I came across RefreshBlock function and it works correctly. I searched the docs and have not found any information on it. I wonder if it is not recommended to use RefreshBlock for some reason? What does RefreshBlock do, does it refresh a block (as the name suggests) or is it equivalent to Refresh?
I am using wxWidgets 3.2 on Win10.
Thanks in advance.
The function RefreshBlock() is indeed the best way to do what you want and it was only undocumented by mistake, i.e. we simply forgot to do it. I've added documentation for it only now, so it will only get included in 3.2.1, but you can still use it in your code, the function itself is available since 3.1.3.
It seems from the source code that, depending on the location of its parameters, RefreshBlock refreshes any of the following:
corner grid
frozen cols grid
frozen rows grid
main grid
Since the area I wanted to refresh was on the main grid the following approach works (the idea is similar to RefreshBlock's approach):
auto GridWnd = CellToGridWindow(TL);
wxRect rect = BlockToDeviceRect(TL, BR, GridWnd);
GetGridWindow()->RefreshRect(rect);
Now everything is refreshed correctly.
Notes:
If only RefreshRect(rect) is called, things will NOT work as expected.
Little experiment showed that BlockToDeviceRect(TL, BR) also works, therefore eliminating the need for auto GridWnd = CellToGridWindow(TL);
I'm using the Google Calendar API to create new events. It appears the only method to assign a color to an event is with a colorID (1 to 11) that looks up the specific color from the table.
The default 11 color palette isn't exactly ideal for my needs so I would like to change it but I haven't been able to figure out how. The documentation explains how to obtain these lookup tables and but I can't figure out how to modify them. I assume they can be modified as there is a timestamp in the structure for the last time it was modified.
Anybody know how to modify the colorID table for events?
I know this thread is old, but the answer to the question is that you can't edit the set Event colors. The new custom colors in the new API only correlate with the Calendar color itself, not the Events contained within.
Why Google would only make some of the colors customizable, and not all beats me. Until they realize the desire for more colors it would appear we are stuck with good ol' 1-11.
Added detail from bounty:
I have the same question. I would like to be able to set a custom color for events that I post to the calendar, but don't want to be
limited by the 11 choices. I see in the docs they have added an
additional color setting method
(https://developers.google.com/google-apps/calendar/v3/whats-new#custom_colors_for_calendars).
But I'm unclear on the concept of how to go about it.
This part of the documentation demonstrates these properties directly: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert
Which will let you add and modify your personal calendar as a demo (scroll to the bottom and try out the API Explorer). To do what you are asking on here, set colorRgbFormat=true then add the backgroundColor or foregroundColor properties with the specified color.
You end up with a request which looks like:
POST https://www.googleapis.com/calendar/v3/users/me/calendarList?colorRgbFormat=true&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer xxxx
X-JavaScript-User-Agent: Google APIs Explorer
{
"id": "SomeCalendarItem",
"backgroundColor": "#444444"
}
Note: I think this answers the bounty question - which is different from what the OP asked, but might be what the OP wanted - #Wescotte, please advise if this solves (or doesn't) your issue as well.
This javascript code hides all the markers on a google map which I initially populated using the gmaps4rails gem in a Rails 3.2 app.
var markers=Gmaps.map.markers
for(i=0;i<markers.length;i++){markers[i].serviceObject.setVisible(false); }
The issue I have is that the "clusters" still show the same counters before and after the above code is ran. I've searched around a bit and haven't figured out the write line(s) to add to update the clusters.
P.S. I'm pretty sure that "cluster" is the correct name for what I'm talking about. What I'm referring to are the counters that the map shows when you are zoomed out to a view where there isn't enough room to distinguish between individual markers and the map shows a colored, circularish icon with a count of the number of map markers in that area.
If you want to update your map with a different set of markers, we'll call them differentMarkers you can call
var differentMarkers = ...
Gmaps.map.replaceMarkers(differentMarkers);
and the clusters will update.
If you want to add markers to the existing set use
var additionalMarkers = ...
Gmaps.map.addMarkers(additionalMarkers);
I haven't found a method to remove markers but you could call the replaceMarkers with an array that has the markers removed.
Not sure if this is the way it is meant to be done but seems to work.
Adding and replacing markers this way is also explained in the wiki for gmaps4rails. https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Javascript-goodies
I am developing a Demo project in Xcode to draw a route between two places.
For example, from a particular starting place to end place according to latitude and longitude. However, I could not understand how to do it? With the help of google api or from any other process?
To draw a line between the starting point and ending point the best place to start is the Apple Source Code Here, it does everything and more: http://developer.apple.com/library/ios/#samplecode/Breadcrumb/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010048-Intro-DontLinkElementID_2
You need to make a request to http://maps.google.com/maps?dirflg=w&output=dragdir&saddr=lat,lng&daddr=lat,lng ( more information on parameters can be found here: http://mapki.com/wiki/Google_Map_Parameters#Directions )
It will return points in encoded format, decode them using code from http://fkn1337.com/decode-google-maps-polylines-objective-c/
Construct MKPolyline object from this points and add it to the map.
If you want to draw route between two points in map view it is better to use Regexkitlite framework classes which will describe clearly how to achieve this.For reference and sample code go through this link.
http://sugartin.info/2011/10/12/drawing-route-on-google-map-mkmapview
I'm sure you've all seen this error before in your Titanium mobile projects. I've been getting it in an app I'm working on. It is usually thrown by the same type of operation, but not all the time and not in the same place. I'm wondering if anyone has found a solution to this issue yet.
The error is usually generated when I am iterating through an array of objects, and using that data to create views. Each new view is below its previous sibling, so the new view's top property looks something like this:
top = (from_top + old_view.height + 10);
As you can see I'm using the view.height property to figure out my top property, and I assume this is part of the problem. Anyone had any luck with this, or are you using a work around to avoid using a view's height property in addition?
(This is also posted on the Appcelerator Q&A site)
Why don't you use layout: 'vertical' instead of manually specifying the heights? It isn't in the docs at the moment, but as of 1.5 you can specify layout: 'vertical' on windows and scrollviews, possibly on views as well. Works on both iOS and Android.