TypeError: L.TileLayer.sygicRestriction is not a function - sygic-maps

I'm trying to add a truck restrictions layer to my map using Sygic's Leaflet 1.0.3, and their plugin 1.1.0 with an evaluation key. I'm receiving the following error in the FireFox JavaScript console:
TypeError: L.TileLayer.sygicRestriction is not a function
This makes me think that there's a new version of the plugin, but I don't know the URL since it's not in the documentation.
NOTE: It might be nice to always host the latest like:
https://maps.api.sygic.com/js/leaflet.sygic-latest.js
or just:
https://maps.api.sygic.com/js/leaflet.sygic.js
Here's an excerpt from my code, which is pretty much the same as the example in the online documentation:
<link rel="stylesheet" href="https://maps.api.sygic.com/js/leaflet/1.0.3/leaflet.css">
<link rel="stylesheet" href="https://maps.api.sygic.com/js/sygic/1.2.0/leaflet.sygic.css" />
<script src="https://maps.api.sygic.com/js/leaflet/1.0.3/leaflet.js"></script>
<!-- *** Is there a newer version of the sygic leaflet plugin? ** -->
<script src="https://maps.api.sygic.com/js/leaflet.sygic-1.1.0.js"></script>
...
var map = L.map('mapContainer');
L.TileLayer.sygic('***MY KEY ***',{poi:true,restriction:true}).addTo(map);
L.TileLayer.sygicRestriction('*** MY KEY ****', {categories: ['NoTruck', 'MaxHeight']}).addTo(map);
Any ideas?

I found the updated plugin URL in the examples posted to GitHub:
<script src="https://maps.api.sygic.com/js/sygic/1.3.0/leaflet.sygic.js"></script>

Related

What does mean by boilerplate in flutter programming? [duplicate]

This question already has answers here:
What is boilerplate code?
(15 answers)
Closed last year.
I have read this word 'boilerplate' in many documents (like equatable plugin in flutter) but don't know what does it mean..! very confused , I thought boilerplate is preparation for code before running the application (like we prepare stuff before cooking food) but now I think I'm wrong , Boilerplates are those codes which repeated in many places in the whole code.
Can anyone make this thing clear to me in flutter (in simple language)?
boilerplate means a piece of code that can be used over and over again in a specifc part of an app, or to do the same operation, maybe with slight modifications. For example all Winforms apps (windows desktop app) start like this
namespace WinFormsApp3 {
internal static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}
in fact this is so 'boilerplate' that it is generated automatically by the IDE. Just a few names get changed.
Most devs dont even look at it because they just recognize it as 'biolerplate'
I dont know flutter but I bet there are similar pieces of code that all flutter apps have
I just read about how to create a flutter app. The automatically generated lib/main.dart is classic boilerplate
another example. THis is bootstraps 'getting started ' page
https://getbootstrap.com/docs/5.1/getting-started/introduction/
Look at the bit headed 'starter template', again this is classic boilerplate. I know I just copy pasted it for my first few apps
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Option 2: Separate Popper and Bootstrap JS -->
<!--
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
-->
</body>
</html>

Use Chartjs-Annotation-Plugin without using "import"

Is there a way to use the newest version of the chart-annotation-plugion as an inline plugin?
How I currently do it:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.1.0/chart.min.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-annotation#1.0.0-rc/dist/chartjs-plugin-annotation.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.0.0-beta.1/chartjs-plugin-datalabels.min.js" ></script>
But in newer versions of ChartJS you need to register your plugins, but I dont think the plugin has a global property to register it, like the datalabel plugin (https://chartjs-plugin-datalabels.netlify.app/guide/getting-started.html#installation) has.
Here are the docs for the annotation plugin: https://www.chartjs.org/chartjs-plugin-annotation/guide/integration.html.
Any help is greatly appreciated.
Late to the party but I don't see a response yet and I was also having trouble figuring it out.
Simply include
<script>
Chart.register('chartjs-plugin-annotation');
Chart.register('chartjs-plugin-datalabels');
// ... rest of your code
</script>
somewhere near the top of your scripts after your CDN imports.
As per the Chartjs plugin documentation, this will work with any plugin that follows the naming convention chartjs-plugin-*
Edit:
Adding a working example; credit to #dennis-bauszus for most of the chart layout.
https://codepen.io/jarrilla/pen/OJjMVEo

How to load ag-grid-react from a CDN

Trying like this (full HTML file contents):
<script src="https://unpkg.com/react#16.5.2/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom#16.5.2/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/ag-grid-community#19.0.0/dist/ag-grid-community.min.js"></script>
<script src="https://unpkg.com/ag-grid-react#19.0.0/umd/ag-grid-react.min.js"></script>
But ag-grid-react doesn't load:
Uncaught TypeError: Cannot read property 'ColDefUtil' of undefined
ag-grid-community.min.js has created window.agGrid and there is ColDefUtil there, but ag-grid-react fails to find it.
Please advise.
I ended up dynamically loading (heavy) ag-grid from a CDN and compiling (light) ag-grid-react into one of app chunks and wiring them together via webpack externals.

How to use Material-UI in asp.net mvc project

Is there a way of using Material-UI without having to go through installing all of the dependencies using NodeJS. I would love to use this in an ASP.NET Project but dont know where to begin as per installing dependencies and all of that.
Technically using Material UI without any frontend infrastructure is possible, but it's not recommended.
If you really don't want to use npm and other JS build/bundling tools you can use the UMD distribution of Material UI.
The Getting started (#CDN) page should help.
In short, you can add React, Babel, and Material UI using plain old script tags in your HTML:
<head>
<script
src="https://unpkg.com/react#latest/umd/react.development.js"
crossorigin="anonymous"
></script>
<script src="https://unpkg.com/react-dom#latest/umd/react-dom.development.js"></script>
<script
src="https://unpkg.com/#mui/material#latest/umd/material-ui.development.js"
crossorigin="anonymous"
></script>
<script
src="https://unpkg.com/babel-standalone#latest/babel.min.js"
crossorigin="anonymous"
></script>
<!-- Fonts to support Material Design -->
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<!-- Icons to support Material Design -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
then write your JS in a <script type="text/babel"> tag:
<script type="text/babel">
const {
Button,
ThemeProvider,
createTheme
} = MaterialUI;
const theme = createTheme();
function App() {
return (
<Button>Hello, world</Button>
);
}
ReactDOM.render(
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>,
document.querySelector('#root'),
);
</script>
<div id="root"></div>
See https://github.com/mui/material-ui/tree/master/examples/cdn for a working example.
This solution is great for prototyping, but not suitable for production apps. The primary reason for this is low performance. Browsers must download the whole library (including the parts you don't use in your application) and Babel must compile your React app on the fly.
A much better approach is to have an ASP.NET API application and a separate frontend application using React and Material UI that is built using JS tools.
it's very easy.. Follow the below steps.
Commit all the existing changes to your source control or backup existing code.
delete or comment twitter bootstrap bundles in bundle config.
using NPN .. install material design lite package.
add all the .css and .js references to bundles.
add new bundles you added to the layout page.
Remember to change all the class that uses twitter bootstrap to material design lite.
useful sources:
Learning Material Design
MDL Website

Is is possible to load .coffee script file to browser and execute?

I am trying to load coffee script inside a sample.coffee file along with the coffee-script.js file and perform some simple operations on the HTML. But i am not able to load the sample.coffee file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="sample.coffee" type="text/coffeescript"></script>
<script src="coffee-script.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
Here is the coffeescript code inside sample.coffee
message = "Welcome to Coffeescript"
alert message
I referred the blog http://forgivingworm.wordpress.com/2010/09/27/running-coffeescript-in-browser/
I trying to run this in MVC4 project on .cshtml. So I am running under MS world.
I am not sure if this is possible or not? any insight into this would be greatly appreciated.
I am able to solve this issue by using the CoffeeSharp http://tomlokhorst.github.com/CoffeeSharp/ It gives handler for .coffee files also converts the coffeescript to javascript on the browser.
Also I am able to compile the coffeescript to javascript during the build event itself which solves deployment and performance related issues.
I dont think this will work like you tried it.
You will need something like requirejs and the coffeescript loader
at https://github.com/jrburke/require-cs.
However I would strongly discourage this and rather have it compiled before loading into the browser (require.js is encouraged though). You might find grunt.js helpful for "building" your app before deploying.
That html works fine for me. I used the coffee-script.js found here: https://cdn.rawgit.com/jashkenas/coffeescript/1.11.1/extras/coffee-script.js and my sample.coffee is:
x = ->
alert("hi")
x()
If you open the Javascript console, do you see any errors?