Laravel 5 Google Maps API Unexpected number - laravel

I am using the google maps API to show a location. The lng/ltg values are stored in my DB. Unfortunately the values in my view are comma separated and an exception is thrown, because the values need to be separated with a point.
SequelPro shows me that the values are separated with points in my DB.
It seems that blade is doing something else with the values.
var lat = 49,3987524;
What can I do to get 49.3987524 instead of 49,3987524?
The error Message is:
4:491 Uncaught SyntaxError: Unexpected number
This is my script:
var lat = {{$restaurant->lat}};
var lng = $restaurant->lng;
var map = new google.maps.Map(document.getElementById('map-canvas'),{
center:{
lat: lat,
lng: lng
},
zoom: 15
});
var marker = new google.maps.Marker({
position:{
lat:lat,
lng: lng
},
map:map
});

Ok, In case somebody has a similar issue.
I solved it with {{str_replace(',','.',$restaurant->lat)}}.

Related

add geojson from arcgis online API to openlayer map

I am trying to get geojson data (point coordinates of a track) using the arcgis online REST API.
var data = {
};
// sends AJAX request and forwards the returned data to the visualiser
data.requestJSON = function(requestParameters) {
$.ajax({
url: "https://services.arcgis.com/........=*&f=geojson" ,
method: 'GET',
success: function(response) {
visualizer.sendDataToMap(response);
},
error: function(error) {
}
});
};
The geojson data should the be processed in another .js and added to a map.
But I cannot turn the data in a vector.
I found some helpful answers here in the forum, but it still does not work.
var visualizer = {}
//prepare the data for visualisation
visualizer.sendDataToMap = function(jsonData) {
console.log("jsondata",jsonData);
var track = new ol.source.Vector({
features: new ol.format.GeoJSON().readFeatures(jsonData)
});
console.log("track",track);
}
The geojson data from the ajax request shown in the console looks as if the right data is passed.
But turning it into a vector, according to some code line I found here in the forum, does not seem to work. I do not understand the console.log.
Can anyone give a hint how to do that?
The console error message looks like
ol.js:319 Uncaught TypeError: b.R is not a function
at mn.l.Va (ol.js:319)
at Object.visualizer.sendDataToMap (visualizer.js:40)
at Object.success (dataProvider.js:10)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at z (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
Or maybe someone has done the same and could provide an example I could try to follow.
Thanks.

Possible Parse bug in matchesKeyInQuery

If a post in my Parse database is liked, I want to send a push to the author via cloud code.
To be able to send pushes to specific users, all installations store the objectId of the current user. To find the author of the liked post, I use the query
var userWhosePostWasLikedQuery = new Parse.Query(Parse.Installation);
userWhosePostWasLikedQuery.equalTo(kClassInstallationKeyCurrentUserId, userWhosePostWasLiked.id);
This works fine: A single push is sent to the author.
Now I want to send this push only if the author has such pushes enabled. Thus each user stores a push settings array with enable flags for different pushes.
I use now another query for all users who have such pushes enabled:
const User = Parse.Object.extend(kClassUser);
var pushEnabledUserQuery = new Parse.Query(User);
pushEnabledUserQuery.equalTo(kClassUserKeyPushSettings, kPushNotificationTypePostLiked);
This query correctly returns all users who have such pushes enabled.
Eventually, I want to constrain the query for installations with the author as current user, by this query for users who have pushes enabled. This is done in the following way:
var userWhosePostWasLikedQuery = new Parse.Query(Parse.Installation);
userWhosePostWasLikedQuery.equalTo(kClassInstallationKeyCurrentUserId, userWhosePostWasLiked.id);
userWhosePostWasLikedQuery.matchesKeyInQuery(kClassInstallationKeyCurrentUserId, kPFObjectId, pushEnabledUserQuery);
Since the old query without the 3rd line returns 1 user, the new query with the additional constraint (matchesKeyInQuery) should return the same user, since the author has pushes enabled.
But it returns 2 users, the author and another user who liked the post.
To my understanding, this looks like a Parse bug, since all constraints to a query are ANDed.
Any ideas, maybe for a workaround?
your var "kPFObjectId" should be change to "user".
the default parse Installation come with the pointer named "user" and not "kPFObjectId".
I can tell you that Im using the same method ("matchesKeyInQuery") and it is working well:
Parse.Cloud.define("sendPushForChat", function(request, response) {
var userId = request.params.userId;
var groupId = request.params.groupId;
var query = new Parse.Query('RecentActivity');
query.equalTo('groupId',groupId);
query.include('user');
query.notEqualTo('user', {__type: "Pointer", className: "_User", objectId: userId});
var queryInstallation = new Parse.Query(Parse.Installation);
queryInstallation.matchesKeyInQuery('user', 'user', query);
var message = request.params.messageContent;
Parse.Push.send({
where: queryInstallation,
data: {
alert: message,
badge: "Increment",
title: "מה נשמע?"
}
}, {
success: function() {
console.log("Push for chat was successful");
response.success('Push for chat was successful');
},
error: function(error) {
console.error(error);
response.error('error');
},
useMasterKey:true,
});
})

doesNotMatch query in Parse not working

I have two objects in Parse. The first one is notification where I save every challenge my user get. The second one is UserChallenge where I store every challenge a user completes. I tried to do a combined query where I only get results of notifications for challenges the user didn't complete and I get nothing in return. I checked my data and I should get two objects back.
Does anyone can tell what I did wrong in the query?
var Completed = Parse.Object.extend("Picok_User_Challenge");
var completedQuery = new Parse.Query(Completed);
completedQuery.equalTo("picok_user_id",currentUser);
var Challenges = Parse.Object.extend("Picok_Notifications");
var challengesQuery = new Parse.Query(Challenges);
challengesQuery.include("new_challenge_id");
challengesQuery.equalTo("type", "CHALLENGE");
challengesQuery.equalTo("who_recived", currentUser);
challengesQuery.doesNotMatchKeyInQuery("new_challenge_id","picok_challenge_id",
completedQuery);
challengesQuery.find({
success: function(results) {
console.log("createNotifiction success count: " + results.length);
response.success("YAY");
},
error: function(object, error)
{
console.log(error);
alert('Failed to get challenge not completed for: ' + request.params.user);
response.error('Failed to get user challenges to complete for: ' + request.params.user);`
}
});

Using Highland in combination with node-client

I'm trying to use highland in combination with the heroku-client. But internally in the heroku client it uses this, even if I try to bind to bind this, the function gives and error message where there is a refrance to this I'm not able to get it to work.
Right no the code looks like this
const Heroku = require('heroku-client');
const hl = require('highland');
var hk = new Heroku({
token: process.env.HEROKU_API_TOKEN
});
var list = hl.wrapCallback(hk.apps().list.bind(hk));
list().toArray((a) => 'console.log(a)')
So this code snippet fails with the following error message:
...node_modules/heroku-client/lib/resourceBuilder.js:35
if (this.params.length !== pathParams.length) {
^
TypeError: Cannot read property 'length' of undefined
Yo! :-)
You're binding to hk and not what hk.apps() return, which is what the list function depends on (it's a member of what hk.apps() returns)
Try this:
const Heroku = require('heroku-client');
const hl = require('highland');
const hk = new Heroku({
token: process.env.HEROKU_API_TOKEN
});
const hkApps = hk.apps();
const list = hl.wrapCallback(hkApps.list.bind(hkApps));
list().toArray((a) => 'console.log(a)')

How get something from Parse.com database?

How show something from parse.com data base ? Give me code please. I just only sturted learning js. For example how show all users. Or how show information about one user. Help please )
Hi I would suggest you to start learning parse ans JS with all the proper documentation provided. Documentations
If you are looking for a simple example using Parse and JS, take a look at the below code,
myObject.fetch({
success: function(myObject) {
// The object was refreshed successfully.
},
error: function(myObject, error) {
// The object was not refreshed successfully.
// error is a Parse.Error with an error code and message.
}
});
Or you can refer to the below example also, where we can make use of handlebar.js to display each blog object.
$(function() {
Parse.$ = jQuery;
// Replace this line with the one on your Quickstart Guide Page
Parse.initialize("KEYS", "KEYS");
// Your Parse application key
var Blog = Parse.Object.extend("Blog");
var Blogs = Parse.Collection.extend({
model: Blog
});
var blogs = new Blogs();
blogs.fetch({
success: function(blogs){
console.log(blogs);
var blogsView = new BlogsView({ collection: blogs });
blogsView.render();
$('.main-container').html(blogsView.el);
},
error: function(blog, error){
console.log(error);_
}
});
var BlogsView = Parse.View.extend({
template: Handlebars.compile($('#blogs-tpl').html()),
render: function(){
var collection = { blog: this.collection.toJSON() };
this.$el.html(this.template(collection));
}
});
});

Resources