Hy guys, I'm trying to load a KML file in path : "/var/www/laravel/public/kml/doc.kml" , but i can't.
The code of import is:
var ctaLayer = new google.maps.KmlLayer({
url: '/var/www/laravel/public/kml/doc.kml',
map: map
});
What I missed?
loading KML formats are loaded like this (begins with http://):
url: 'http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml',
like
var kmlLayer = new google.maps.KmlLayer({
url: 'http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml',
suppressInfoWindows: true,
map: map
});
Your URL seems to be invalid: /var/www/laravel/public/kml/doc.kml
However, if you're running this map on a localhost, make sure you start your local server first.
Related
I'm new with MapHere, I see that with REST API side I can specify waipoints but I can't with JavaScript, I tried some parameters like 'via' but only admit one point:
var routingParameters = {
'routingMode': 'fast',
'transportMode': 'car',
// The start point of the route:
'origin': '36.8414197,-2.4628135',
'via': '37.9923795,-1.1305431',
// The end point of the route:
'destination': '40.4167047,-3.7035825',
// Include the route shape in the response
'return': 'polyline'
};
I saw an example on the main page of javascript web but I can't use waypoints:
var router = platform.getRoutingService(),
routeRequestParams = {
mode: 'fastest;car',
representation: 'display',
routeattributes: 'waypoints,summary,shape,legs',
maneuverattributes: 'direction,action',
waypoint0: '52.5160,13.3779', // Brandenburg Gate
waypoint1: '52.5206,13.3862' // Friedrichstraße Railway Station
};
Throwing the following error:
{"title":"Malformed request","status":400,"code":"E605001","cause":"Error while parsing request: 'origin' parameter is required\n","action":"","correlationId":"1c7bd525-b8af-4989-83a9-ab07f26a8c33"}
So, how I can send request for use waypoints?
EDIT
I saw the problem, when the .js create the url encode the second &via=
https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654%26via%3D51.2234%2C9.1123&return=polyline
If I decode & and = works perfectly
https://router.hereapi.com/v8/routes?xnlp=CL_JSMv3.1.18.1&apikey=***&routingMode=fast&transportMode=car&origin=50.1120%2C8.6834&destination=52.5309%2C13.3846&via=50.1234%2C8.7654&via=51.2234%2C9.1123&return=polyline
The JavaScript API does not yet (as of library version 3.1.18.1) support passing multiple waypoints, meaning passing an array of points to the via parameter. Your best bet around this lack of support would be to use the Routing REST API directly:
https://router.hereapi.com/v8/routes?
origin=52.550464,13.384223
&transportMode=car
&destination=52.477545,13.447395
&via=52.529791,13.401389
&via=52.513079,13.424392
&via=52.487581,13.425079
&apikey={YOUR_API_KEY}
I used npm pkg Sharp on server's picture collection to transform imgs. The server code is like this:
import * as sharp from 'sharp';
export const Pictures = new Mongo.Collection('pictures');
export const PicturesStore = new UploadFS.store.GridFS({
collection: Pictures,
name: 'pictures',
filter: new UploadFS.Filter({
contentTypes: [ 'image/*' ],
}),
transformWrite(from, to, fileId, file) {
const transform = sharp().resize(300, 300).min().crop().toFormat('jpeg', { quality });
from.pipe(transform).pipe(to);
},
})
However on the client, it reports error:
cannot load native .node modules on the client.
The client doesn't run sharp functions actually. It only refers to PicturesStore and also create a minimongo collection for Pictures.
In another project, it uses webpack on the client. It can be configured to resolve sharp with an empty dummy object.
But how to create an empty dummy Sharp object to prevent loading Sharp module on Meteor client without webpack?
It turns out you have to write a Meteor package to define different files loaded on client and server. In you package.js, it's like this:
Package.onUse(function (api) {
api.mainModule('sharp-client.js', 'client');
api.mainModule('sharp-server.js', 'server');
});
In sharp-client.js, it's like this:
export var Sharp = {};
In sharp-server.js, it's like this:
import {
checkNpmVersions
} from 'meteor/tmeasday:check-npm-versions';
checkNpmVersions({
'sharp': '^0.20.5'
}, 'my:awesome-package');
export var Sharp = require('sharp');
done.
I imported restivus using :
meteor add nimble:restivus
And while using Restivus I encounter this error on meteor startup :
"Cannot find name 'Restivus' ".
I can although GET requests but I wonder if it impacts the behavior of the app.
Here is the code used :
if (Meteor.isServer) {
// Global API configuration
var Api = new Restivus({
apiPath: 'api/',
prettyJson: true
});
}
When receiving POSTs my request.body and my bodyParams are empty :
Api.addRoute(':id/test', {
post: function () {
var id = this.urlParams.id;
console.log("Body contains : ");
console.log(this.bodyParams);
return {
status: 'success',
url : 'post test from id: '+id,
body : this.bodyParams
};
}
});
Does anyone know how to make this error disappear and if this is linked to the POST body problem ?
If you use Meteor 1.4+ you can try to import Restivus to your file with something like this:
import Restivus from 'nibmle:restivus';
The problem with post body being empty was caused by the request I made :
I wasn't specifying the Content-type header.
Once I specified the "Content-Type": "application/json" it worked.
The "Cannot find 'Restivus' " Error is still here though.
Your code looks ok. Here is some code from a server-only file that I am using:
// Global API configuration
var Api = new Restivus({
useDefaultAuth: true,
prettyJson: true,
apiPath: 'restAPI/',
defaultHeaders: { 'Content-Type': 'application/json;encoding="UTF-8"' }
});
// Generates: GET, POST on /api/items and GET, PUT, DELETE on
// /api/items/:id for the Items collection
Api.addCollection(Policy);
Perhaps you should move your code to the server directory? I am on Meteor 1.3.4.
So, Im using udondan:jszip, cfs:collection,
cfs:standard-packages and
cfs:filesystem packages in my meteor app. The problem is that I cant store my zip files in the FS.COllection. Here is some of the code :
//Defining the collection
Reports = new FS.Collection('reports',{
stores: [new FS.Store.FileSystem('reports', {path: "~/public"})]
});
//Trying to add a file to the collection
var zip = new JSZip();
Reports.insert(zip);
After running the code Im getting this error:
Error: DataMan constructor received data that it doesn't support
Is there any way to make those packages work with each other ?
The JSZip object is not a file by itself. You can generate a file from it with the generateAsync function. The file type you'll want to create depends on if you want this to run on the client or server and how you want to use this file. The file types supported by both libraries are: (as per documentation, I haven't tested all these myself)
Blob object (client only): { type: 'blob' }
Uint8Array: { type: 'uint8array' }
ArrayBuffer: { type: 'arraybuffer' }
Buffer object (server only): { type: 'nodebuffer' }
So for example this should work:
zip.generateAsync({ type: 'arraybuffer' })
.then(function (content) {
Reports.insert(content);
});
I use gulp to run protractor and want one separate task for each browser, Chrome and Firefox. So by running gulp protractor:chrome or gulp protractor:firefox I would launch different browsers. But I get my capabilities through the getMultiCapabilities and it isn't as simple as --capabilites.browserName chrome then. This is how my getMultiCapabilities-function looks like for Firefox:
'use strict';
var FirefoxProfile = require('firefox-profile');
var bbPromise = require('bluebird');
exports.getMultiCapabilities = function () {
var deferred = bbPromise.defer();
var firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference('media.navigator.permission.disabled', true);
firefoxProfile.encoded(function (encodedProfile) {
var capabilities = [{
browserName: 'firefox',
firefox_profile : encodedProfile
}];
deferred.resolve(capabilities);
});
return deferred.promise;
};
And I want to use this function by passing it in the command line somehow. I tried just requiring the function in the config file and then doing --getMultiCapabilities firefoxCapabilitiesHelper.getMultiCapabilities. Didn't work. Also tried to "stringify" the function and wrote everything inside it on the command line. Didn't work either. The arguments are ignored.
Is it even possible to do what I want to achieve?