Linking to another page from a google maps marker - c#

I am coding in c# and using the Artem.Google v6 package to create my map on my website. I am trying to create links from the markers that are dropped onto the map, all of the markers need to link to the same page but with a different ID. strID contains the entire address that each marker needs to link to. This is how I create the marker:
Marker m = new Marker() { Address = strAddress, Info = strName, Animation = MarkerAnimation.Drop };
m.Info = ConvertStringToLink(strID);
GoogleMap1.Markers.Add(m);
I made this method to try and change the marker's Info into a link:
private string ConvertStringToLink(string msg)
{
string regex = #"((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:#=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
Regex r = new Regex(regex, RegexOptions.IgnoreCase);
return r.Replace(msg, "$1").Replace("href=\"www", "href=\"http://www");
}
So that doesn't change the text in the info popup to a link. Am I on the right track here or do I need to do it another way?

So to get it to work I just formatted the info of the marker to turn it into a link.
strName = String.Format("{0}", strName, strID);
Marker m = new Marker() { Address = strAddress, Info = strName, Animation = MarkerAnimation.Drop };

Related

How do you add thumbnails to an embed message in DSharpPlus?

I have been bashing my head against the wall for 8 hours now, trying to figure out how to add thumbnails to embeded messages. I've been following this tutorial that uses ThumbnailURL, something that doesn't exist in the context he's using it for. Instead I just have Thumbnail which does not take a string, but rather an EmbedThumbnail which I can't access at all.
var avatarEmbed = new DiscordEmbedBuilder
{
Title = "Enter the game.",
Thumbnail = ctx.Client.CurrentUser.AvatarUrl,
Color = DiscordColor.Azure,
};
Please don't send links to docs and tutorials. I've tried. I've really tried. But this just seems like an issue that is very recent and therefore resources on it would be next to none. Also the docs don't seem to have example code, making it all more frustrating.
Not sure about your version but I use the latest nightly build.
and I do it like this
var builder = new DiscordEmbedBuilder
{
Title = "Title Here",
Color = DiscordColor.Azure
};
builder.WithThumbnail(ctx.Client.CurrentUser.AvatarUrl);
but you can also do it this way
var builder = new DiscordEmbedBuilder
{
Title = "Title Here",
Color = DiscordColor.Azure,
Thumbnail = new DiscordEmbedBuilder.EmbedThumbnail
{
Url = ctx.Client.CurrentUser.AvatarUrl
}
};

C# Google Calendar

Everything is already setup on the google calendar api (not sure if i configure correctly or i missed something out)
I created a c# console application,that writes an appointment to google calendar.
What i want to achieve is that , i want to get all the user's or subscriber who subscribe to my app, so what i can write
on there calendar if there is an event.
What configuration do i need?
That's actually a multi-domain problem.
Some questions to consider:
What calender is it? A public one?
How do they subscribe with your console?
What happens when the software shuts down, crashes, etc?
Do you need to know the event after it was written to the calendars?
If not, do new subscriber get previously added calender entries?
Other than that, you should have a look at Webclient. Then we have here the reference for the Google Calendar API. The main request method you're searching is this one: Events Insert. With that, we can craft our own inseration variant.
```
private readonly List<string> _calendarIDs;
/* lets assume you imported webrequests and you're going to write a method
* Further we assume, you have a List of calendars as object attribute
*/
public void InsertEntry(DateTime start, DateTime end,
string title, string description) {
using(var client = new WebClient()) {
var epochTicks = new DateTime(1970, 1, 1);
var values = new NameValueCollection();
values["attachements[].fileUrl"] = "";
values["attendees[].email"] = "";
values["end.date"] = end.ToString("yyyy-MM-dd");
values["end.dateTime"] = (end - epoch).Seconds;
values["reminders.overrides[].minutes"] = 0;
values["start.date"] = start.ToString("yyyy-MM-dd");
values["start.dateTime"] = (start - epoch).Seconds;
values["summary"] = title; // This is the calendar entrys title
values["description"] = description;
foreach(string calendarID in _calendarIDs) {
var endpoint = String.Format("https://www.googleapis.com/calendar/v3/calendars/{0}/events", calendarID)
var response = client.UploadValues(endpoint, values);
var responseString = Encoding.Default.GetString(response);
}
}
This is a minimal example and the api has a lot of endpoints and parameter. You should have a deep look into it, maybe you find more useful parameter.
Below is the sample code,
GoogleCalendarUtils utils = new GoogleCalendarUtils();
ArrayList months = /* the list of months*/;
// Update the content window.
foreach( ThistleEventMonth month in months )
{
foreach( ThistleEvent thistleEvent in month.ThistleEvents )
{
utils.InsertEntry( thistleEvent );
}
}

C# Youtube - I want to delete video from my Youtube channel

I want to delete videos from my YouTube channel which video ids are selected, though MultiSelection property of ListBox is on, code doesn't work, is there any other solution? I get such an error as follows:
Execution of request failed: http://gdata.youtube.com/feeds/api/users/xxxxxx/uploads/System.Windows.Forms.ListBox+SelectedObjectCollection
Here is my code:
public void delete()
{
YouTubeRequestSettings settings = new YouTubeRequestSettings(my app name,
my dev key,
my username,
my password);
YouTubeRequest request = new YouTubeRequest(settings);
Uri videoEntryUrl = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", my channel name, list.checkedItems));
Video video = request.Retrieve<Video>(videoEntryUrl);
request.Delete(video);
}
Code for Populating the CheckedListBox
Feed<Video> videoFeed;
string feedUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads";
videoFeed = request.Get<Video>(new Uri(feedUrl));
foreach (Video entry in videoFeed.Entries)
{
list.Items.Add(entry.VideoId,0);
}
Ok...I think the key here is to get the data out of the object collection - and an easy way to do that is with a foreach loop. I'm not familiar with the YouTube API so I don't know what format it expects the video ID in (for multiple videos), but for purposes of this example I'll use a comma.
string videoIDs = "";
foreach (object vidID in list.CheckedItems)
{
videoIDs = videoIDs + vidID.ToString() + ",";
}
videoIDs = videoIDs.Substring(0, videoIDs.Length - 1);
Basically, the above code loops through the CheckedListBox.CheckedItemCollection and gets the video IDs, which is what you are storing in the CheckedBoxList from the code you provided.
Then you can simply use the videoIDs string in your code:
Uri videoEntryUrl = new Uri(String.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads/{1}", my channel name, videoIDs));
Again, this is a general approach - you will need to modify the code to fit the YouTube API.
Feed<Video> videoFeed;
string feedUrl = "https://gdata.youtube.com/feeds/api/users/default/uploads";
videoFeed = request.Get<Video>(new Uri(feedUrl));
foreach (Video entry in videoFeed.Entries)
{
list.Items.Add(entry.VideoId,0);
}

C# Project Google map

For my studying and university I have a project where I need to make an application using C# WPF. This application must allow me to select a path between two adresses and show the path on the map like google map.
How can I implement the google webservice API ? I am a bit lost with it and I don't understand how I can make my application and fit in the google map itself.
With this i must be able to calculate the distance as well.
This is what i have done with the webBrowser but it displays the whole website of google maps:
I know that the WebBrowser control can display the google maps but it doesnt actually work
This is my code actually
private void btnCharger_Click(object sender, RoutedEventArgs e)
{
//Use static or WebControl we don't know yet.
//This is the case we use webControl
string street = "";
string city = "";
string zipcode = "";
StringBuilder adresseQuery = new StringBuilder();
adresseQuery.Append("http://maps.google.com/maps?q=");
street = tbStreet.Text.Replace(" ", "+");
adresseQuery.Append(street + ",+");
city = tbCity.Text;
adresseQuery.Append(city + ",+");
zipcode = tbZipCode.Text;
webBrowser1.Navigate(adresseQuery.ToString());*/
}
So in this code i have created the adresse and sent it to the webbrowser through google maps. But is shows the whole google map page with the left bar and everything. I would like to only display the map ! How can i only display the map and not the bars present on the https://maps.google.com/
I have already checked this Link and am currently working on it but this is static.
For the part of routing/getting the directions (and for some of others functions you need as well), you can use a .NET wrapper around Google Maps API:
GoogleApi
google-maps
gmaps-api-net is outdated (at this time of answering) - the last update for the Directions API was made in 2016.
Usage example for GoogleApi:
using GoogleApi.Entities.Common;
using GoogleApi.Entities.Maps.Directions.Request;
using GoogleApi.Entities.Maps.Directions.Response;
public void GetRoute()
{
DirectionsRequest request = new DirectionsRequest();
request.Key = "AIzaSyAJgBs8LYok3rt15rZUg4aUxYIAYyFzNcw";
request.Origin = new Location("Brasov");
request.Destination = new Location("Merghindeal");
var response = GoogleApi.GoogleMaps.Directions.Query(request);
Console.WriteLine(response.Routes.First().Legs.First().DurationInTraffic);
Console.WriteLine(response.Routes.First().Legs.First().Distance);
Console.WriteLine(response.Routes.First().Legs.First().Steps);
}

Google Sites API - File Cabinets: Spaces and extension separator (.) are removed from file names

We have a series of internal reports that we update regularly from our internal databases. We built an application in C# that uploads these reports to a Google Site. Everything works fine, except that the name of the file shown to the final user in the File Cabinet does not include the original spaces nor the extension separator (.)
For example, Stock per warehouse.pdf is shown as : Stockperwarehousepdf
Below is a simplified version of the code.
private AtomEntry UploadAttachment(string filename, AtomEntry parent, string title, string description)
{
SiteEntry entry = new SiteEntry();
AtomCategory category = new AtomCategory(SitesService.ATTACHMENT_TERM, SitesService.KIND_SCHEME);
category.Label = "attachment";
entry.Categories.Add(category);
AtomLink parentLink = new AtomLink(AtomLink.ATOM_TYPE, SitesService.PARENT_REL);
parentLink.HRef = parent.SelfUri;
entry.Links.Add(parentLink);
entry.MediaSource = new MediaFileSource(filename, MediaFileSource.GetContentTypeForFileName(filename));
entry.Content.Type = MediaFileSource.GetContentTypeForFileName(filename);
entry.Title.Text= title;
entry.Summary.Text = description;
AtomEntry newEntry = null;
newEntry = service.Insert(new Uri(makeFeedUri("content")), entry);
}
The key line is where the MediaFileSource object is created. Any idea of what we are missing? I've tried all sort of changes :(
entry.Title.Text = entry.MediaSource.Name;
is missing

Categories

Resources