Having placeId I need to get place details. I can do this with the following code:
var service = new google.maps.places.PlacesService(document.createElement("div"));
service.getDetails({
placeId: locationReference
}, parseLocationDetailResponse.bind(null, function(addressObject) {
deferred.resolve(addressObject);
}));
How can I manually specify language for place details object?
Google maps provides list of languages you need. Simple adding the &language=(type of language) in script scr
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&language=ja"></script>
<div id="map-canvas"></div>
Related
I want to show 30 days in Day View Scheduler with Horizontal Scrollbar. Currently, Horizontal Scrollbar is available only for Timeline View but I want it for Day View as well as Month View.
For Timeline View with Horizontal Scrollbar code:
scheduler.createTimelineView({
name: "timeline",
x_unit: "minute",
x_date: "%H:%i",
x_step: 30,
x_size: 24*7,
x_start: 16,
x_length: 48,
y_unit: sections,
y_property: "section_id",
render: "bar",
scrollable: true,
column_width: 70,
scroll_position:new Date(2018, 0, 15) });
Please share your ideas and Sample links
Thanks in Advance
Try using Custom View. You can remove the default Day view and display your own instead, with the number of days you want to display. This can be done like this:
First in scheduler.config.header set tab "thirty_days" instead of "day":
scheduler.config.header = [
"thirty_days",
"week",
"month",
"date",
"prev",
"today",
"next"
];
The label for the view is set as in:
scheduler.locale.labels.thirty_days_tab = "Days";
Next, set the start date of the viewing interval, as well as viewing templates. It's better to create the custom view in the onTemplatesReady event handler function so that your custom view templates are ready before the scheduler is initialized:
scheduler.attachEvent("onTemplatesReady", () => {
scheduler.date.thirty_days_start = function(date) {
const ndate = new Date(date.valueOf());
ndate.setDate(Math.floor(date.getDate()/10)*10+1);
return this.date_part(ndate);
}
scheduler.date.add_thirty_days = function(date,inc) {
return scheduler.date.add(date,inc*30,"day");
}
const format = scheduler.date.date_to_str(scheduler.config.month_day);
scheduler.templates.thirty_days_date = scheduler.templates.week_date;
scheduler.templates.thirty_days_scale_date = function(date) {
return format(date);
};
});
To add horizontal scrolling to the view, you can place the scheduler inside the scrollable element and give the scheduler the width required to display all columns. You'll need to hide a default navigation panel of the scheduler and create a custom one with HTML, so it would have a correct width and won't be affected by scrolling:
scheduler.xy.nav_height = 0;
scheduler.attachEvent("onSchedulerReady", function () {
const navBar = scheduler.$container.querySelector(".dhx_cal_navline").cloneNode(true);
navBar.style.width = "100%";
document.querySelector(".custom-scheduler-header").appendChild(navBar);
document.querySelectorAll(".custom-scheduler-header .dhx_cal_tab").forEach(function (tab) {
tab.onclick = function () {
const name = tab.getAttribute("name");
const view = name.substr(0, name.length - 4);
scheduler.setCurrentView(null, view);
};
});
document.querySelector(".custom-scheduler-header .dhx_cal_prev_button").onclick = function () {
const state = scheduler.getState();
scheduler.setCurrentView(scheduler.date.add(state.date, -1, state.mode));
};
document.querySelector(".custom-scheduler-header .dhx_cal_next_button").onclick = function () {
const state = scheduler.getState();
scheduler.setCurrentView(scheduler.date.add(state.date, 1, state.mode));
};
document.querySelector(".custom-scheduler-header .dhx_cal_today_button").onclick = function () {
scheduler.setCurrentView(new Date());
};
scheduler.attachEvent("onBeforeViewChange", (oldView, oldDate, newView, newDate) => {
const innerContainer = document.getElementById("scheduler_here");
if (newView === "thirty_days") {
innerContainer.style.width = "3000px";
} else {
innerContainer.style.width = "100%";
}
return true;
});
scheduler.attachEvent("onViewChange", function (view, date) {
const dateLabel = document.querySelector(".custom-scheduler-header .dhx_cal_date");
const state = scheduler.getState();
dateLabel.innerHTML = scheduler.templates[view + "_date"](state.min_date, state.max_date);
document.querySelectorAll(".custom-scheduler-header .dhx_cal_tab").forEach(function(tab) {
tab.classList.remove("active");
});
const activeTab = document.querySelector(".custom-scheduler-header ." + view + "_tab");
if (activeTab) {
activeTab.classList.add("active");
}
});
});
Styles that you will need:
.custom-scheduler-header .dhx_cal_navline{
display: block !important;
height: 60px !important;
}
.custom-scheduler-header .dhx_cal_navline.dhx_cal_navline_flex{
display: flex !important;
}
.dhx-scheduler {
height: 100vh;
width: 100vw;
position: relative;
overflow: hidden;
background-color: #fff;
font-family: Roboto, Arial;
font-size: 14px;
}
.dhx_cal_container .dhx_cal_navline {
display: none;
}
Please see an example: https://snippet.dhtmlx.com/znd7ffiv
You may need to fix the hour scale so that it remains visible when scrolling horizontally on the calendar. I did not implement this in the example, I think that this can be done in the same way as for the navigation panel. If you need, write to me and I will send an update in a few working days.
As for the "Month" view, the approach is the same as for the "Day" view.
I have problem with Rogue Engine Ui.
I have a clickable div and I want to do something if clicked.
Here is my javascript class in RogueEngine :
start() {
this.initializeUi();
}
async initializeUi(){
const htmlPath = RE.getStaticPath("ui.html");
const gameUi = await (await fetch(htmlPath)).text();
RE.Runtime.uiContainer.innerHTML = gameUi;
this.button = document.getElementById("turbine-btn");
this.button.onclick = () => this.onButtonClick();
}
onButtonClick() {
this.button.style.display = "none";
RE.Debug.log("Hooorah!!!!");
}
And here is my HTML file in the root of the "Static" folder:
<div id="turbine-btn" class="clickable">dfafdsafsdfsd</div>
<style>
.clickable {
cursor: pointer;
text-decoration: underline;
}
</style>
When I click, nothing happens. Does anyone know what's the problem with this?
in OL 6 I would like to use a button, so a user can click to activate a change for the drag zoom control
so it will be available without holding down shift.
In https://openlayers.org/en/latest/apidoc/module-ol_interaction_DragZoom-DragZoom.html it lists the option 'condition' to handles this.
I could not figure out how to change and set that condition. Any examples how to do this?
Here my example, hope be usefull.
You can change the style with CSS or in your JS.
HTML code:
<style>
.ol-dragzoom {
border-color: red !important;
}
</style>
<div id="map"></div>
<div id="tool-zoom" class="shadow-sm">
<a id="tool-lupa" class="text-secondary">
<i class="icono-arg-lupa"></i>
</a>
</div>
And the JS code:
var aplica_lupa = function(e) {
const dragZoom = new ol.interaction.DragZoom({
condition : ol.events.condition.always,
})
map.addInteraction(dragZoom);
};
$("#tool-lupa").on("click",function() {
aplica_lupa();
})
If you are importing OL methods, avoid the "ol.interaction...".
And if you want to change the DragZoom style in your JS, try something like this:
const dragZoom = new ol.interaction.DragZoom({
condition : ol.events.condition.always,
style : new ol.style.Style({
fill : new ol.style.Fill({
color : 'rgba(255, 255, 255, 0.6)'
}),
stroke : new ol.style.Stroke({
color : '#CD4D64',
width : 3
})
})
});
And other option, with onclick remove interaction:
const dragZoom = new ol.interaction.DragZoom({
condition : ol.events.condition.always,
})
var aplica_lupa = function(e) {
map.addInteraction(dragZoom);
};
var remueve_lupa = function(e) {
map.removeInteraction(dragZoom);
};
$('#tool-lupa').bind('click', myHandlerFunction);
var first = true;
function myHandlerFunction(e) {
if(first){
document.body.style.cursor="all-scroll";
aplica_lupa();
}else{
document.body.style.cursor="default";
remueve_lupa();
}
first = !first;
}
I'm trying to embed a YouTube video into my Windows 10 Universal App. I know there is ways to do it that goes against the terms on YouTube, but is there a way to do this that doesn't go against them?
I've tried the following code, and I was able to get a YouTube player up. But the video doesn't load.
Under Initialize
string html = #"<style> body{margin:0; padding:0;} iframe{width:100%;height:480px;}#media screen and (max-width:300px) { iframe{width:100%;height:180px;}} </style><iframe style=""padding:0px;margin-bottom:-20px;"" src=""https://www.youtube.com/embed/OLE5oAZanA4" + #" ? rel=0"" frameborder=""0"" allowfullscreen></iframe>";
videoView.NavigateToString(html);
UI code
<WebView Name="videoView" HorizontalAlignment="Left" Height="297" Margin="466,150,0,0" Grid.Row="1" VerticalAlignment="Top" Width="441"/>
For anyone that does use MyToolkit (which goes against YT terms). Is the views still being tracked when you use this method?
try this
StringBuilder stringbuild = new StringBuilder();
stringbuild.Append("<!DOCTYPE html>");
stringbuild.Append("<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">");
stringbuild.Append("<head> <meta charset=\"utf-8\"/> <title></title> </head>");
stringbuild.Append("<body>");
stringbuild.Append(" <style> iframe {border: none;}");
stringbuild.Append(" html, body {margin: 0px; padding: 0px; border: 0px; width: 100%; height: 100%; overflow:hidden;} </style>");
stringbuild.Append(" <div id=\"player\" style=\"width:200px; height:400px;\"></div>");
stringbuild.Append("<script>");
stringbuild.Append("var tag = document.createElement('script');");
stringbuild.Append("tag.src = \"https://www.youtube.com/iframe_api\";");
stringbuild.Append("var firstScriptTag = document.getElementsByTagName('script')[0];");
stringbuild.Append(" firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);");
stringbuild.Append(" function onYouTubeIframeAPIReady() {window.external.notify(\"YoutubePlayerLoadCompleted\"); }");
stringbuild.Append(" var width; var height;");
stringbuild.Append(" function setwidth(incoming) { width = incoming; document.getElementById(\"player\").style.width = incoming+ 'px'; }");
stringbuild.Append("function setheight(incoming) { height = incoming; document.getElementById(\"player\").style.height = incoming +'px'; }");
stringbuild.Append("var player;");
stringbuild.Append(" function loadplayer(incomming) { player = new YT.Player('player', { height: height, width: width, playerVars: { 'fs': 1 }, videoId: incomming, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); var element = document.getElementById('videoframe'); }");
stringbuild.Append("function onPlayerReady(event) { }");
stringbuild.Append("function onPlayerStateChange(event) {}");
stringbuild.Append("function play() { if (!player){} else { try { player.playVideo();} catch(err){window.external.notify(err.message);} }}");
stringbuild.Append(" function pause() { player.pauseVideo(); }");
stringbuild.Append("</script> </body> </html>");
string ts = stringbuild.ToString();
webview.NavigateToString(ts);
webview.ScriptNotify += async delegate (object sender1, NotifyEventArgs e1)
{
var jsScriptValue = e1.Value;
if (jsScriptValue.ToString().Equals("YoutubePlayerLoadCompleted"))
{
await webview.InvokeScriptAsync("setwidth", new string[] {"500" });
await webview.InvokeScriptAsync("setheight", new string[] {"400" });
await webview.InvokeScriptAsync("loadplayer", new string[] { "_P9lGTiiXW0" });
}
};
Last few days i was trying to get jqgrid with autocompletion fields to work, now i can get it to work with local data, but as soon as i trying to get data from my controller data didnt get parsed.
View code:
{ name: 'EanNummer', index: 'EanNummer', width: 65, sortable: true, editable: true, edittype: 'text', editoptions: {
dataInit:
function (elem) {
$(elem).autocomplete({ minLength: 0, source: '#Url.Action("GetBrands")' })
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.Id + ", " + item.Name + "</a>")
.appendTo(ul);
};
}
}
},
if instead of source: url i use source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] for example code works fine and shows up, so something must be wrong with my controller side code
Controller Code:
public JsonResult GetBrands()
{
string vendorId = "";
var username = "";
var name = System.Web.HttpContext.Current.User.Identity.Name;
var charArray = name.Split("\\".ToCharArray());
username = charArray.Last();
vendorId = service.GetVendorIdByUsername(username);
List<String> list = new List<String>();
var brands = service.getBrandsByVendor(vendorId);
var s= (from brand in brands
select new
{
Id = brand.BrandId,
Name = brand.BrandName
}).ToList();
return Json(s);
}
If you use item.Id and item.Name on the client side you should return not the List<String>. Instead of that you should returns the list of new {Id=brand.BrandId, Name=brand.BrandName}. You should just use LINQ instead of foreach:
return Json ((from brand in brands
select new {
Id = brand.BrandId,
Name = brand.BrandName
}).ToList());
UPDATED: I modified for you the demo from the answer and included jQuery UI Autocomplete support in two forms. The standard rendering:
and the custom rendering:
The Autocomplete functionality works in Advanced Searching dialog in the same way like in the Searching Toolbar:
You can download the demo from here.
The server code of the standard autocomplete is
public JsonResult GetTitleAutocomplete (string term) {
var context = new HaackOverflowEntities();
return Json ((from item in context.Questions
where item.Title.Contains (term)
select item.Title).ToList(),
JsonRequestBehavior.AllowGet);
}
It returns array of strings in JSON format. The list of Titles are filtered by term argument which will be initialized to the string typed in the input field.
The server code of the custom autocomplete is
public JsonResult GetIds (string term) {
var context = new HaackOverflowEntities();
return Json ((from item in context.Questions
where SqlFunctions.StringConvert((decimal ?)item.Id).Contains(term)
select new {
value = item.Id,
//votes = item.Votes,
title = item.Title
}).ToList (),
JsonRequestBehavior.AllowGet);
}
It uses SqlFunctions.StringConvert to be able to use LIKE in comparing of the integers. Moreover it returns the list of objects having value the title property. If you would return objects having value the lable properties the values from the lable properties will be displayed in the Autocomplete context menu and the corresponding value property will be inserted in the input field. We use custom title property instead.
The code of the client side is
searchoptions: {
dataInit: function (elem) {
$(elem).autocomplete({ source: '<%= Url.Action("GetTitleAutocomplete") %>' });
}
}
for the standard rendering and
searchoptions: {
sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge'],
dataInit: function (elem) {
// it demonstrates custom item rendering
$(elem).autocomplete({ source: '<%= Url.Action("GetIds") %>' })
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><span style='display:inline-block;width:60px;'><b>" +
item.value + "</b></span>" + item.title + "</a>")
.appendTo(ul);
};
}
}
for the custom rendering.
Additionally I use some CSS settings:
.ui-autocomplete {
/* for IE6 which not support max-height it can be width: 350px; */
max-height: 300px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
/* add padding to account for vertical scrollbar */
padding-right: 20px;
}
/*.ui-autocomplete.ui-menu { opacity: 0.9; }*/
.ui-autocomplete.ui-menu .ui-menu-item { font-size: 0.75em; }
.ui-autocomplete.ui-menu a.ui-state-hover { border-color: Tomato }
.ui-resizable-handle {
z-index: inherit !important;
}
You can uncomment .ui-autocomplete.ui-menu { opacity: 0.9; } setting if you want to have some small
opacity effect in the autocomplete context menu.