w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
how to pass data with marker in leaflet js
It sounds like you would like to add new functionality (functions, properties, etc) to an existing class. It would make sense to use object-oriented principals for this. For this purpose, I'd recommend you extending the CircleMarker class to add those properties. customCircleMarker = L.CircleMarker.extend({ options: { someCustomProperty: 'Custom data!', anotherCustomProperty: 'More data!' } }); Now when you create your circle marker, create an instance of your extended object instead. var myMarker = new customCircleMarker(myPoint, { title: 'unselected', radius: 20, someCustomProperty: 'Adding custom data to this marker!', anotherCustomProperty: 'More custom data to this marker!' }); myMarker.addTo(map); Now you can get the properties like you woul

Categories : Javascript

Angularjs how to pass in data using a directive
Try something like this: .directive('getWidth', function(){ return{ controller: 'QuotesCtrl', link: function(scope){ console.log(scope.theRowHeight); }, scope: { 'theRowHeight': '=' } } }); Markup: <div the-row-height="20"></div>

Categories : Javascript

AngularJS - Pass object data into modal
It helps to know which $dialog service you are referring to exactly, since $dialog is not the part of core AngularJS API. Assuming that you are using the $dialog service from the ui-bootstrap, you can pass your user object into the dialog controller through the resolve property of $dialog configuration object. As the $dialog documentation states it: resolve: members that will be resolved and passed to the controller as locals function DepCtrl($scope, Dependents, $dialog) { $scope.data = Dependents; $scope.opts = { backdrop: true, keyboard: true, dialogFade: true, backdropClick: false, template: t, // OR: templateUrl: 'path/to/view.html', controller: 'TestDialogController', resolve: { user: function(){ return $scope.data; }

Categories : Javascript

AngularJS service/controller not updating angular-leaflet-directive map
I had a similar issue. In my case, I have a div tied to a controller wrapping the leaflet tag element: <div ng-controller="MapCtrl"> <leaflet id="map" class="map" maxBounds="maxBounds" defaults="defaults" center="center"></leaflet> </div> As you can imagine, the values for "maxBounds", "defaults", and "center" were in the parent $scope, not the $scope of the directive. To mitigate this, I had to modify the angular-leaflet-directive code to look up the scope stack for these variables: var mapScope = $scope; if (mapScope.defaults === null || typeof mapScope.defaults === "undefined") { mapScope = mapScope.$parent; } if (mapScope.defaults === null || typeof mapScope.defaults === "undefined") { throw new Error("Cannot find map defaults - have they been in

Categories : Angularjs

how to pass data from compile to linking function in angularjs?
I think it's enough considering the scope of JavaScript symbols. See this http://jsfiddle.net/JV7vH/1/ you define a compile function that has to return a link function. because it's an inner function, symbols from parent functions are visible. app.directive('ui',function ($compile) { return { restrict:'E', template: '<div class="mcb">hey</div>', compile: function ($tElement, $tAttrs) { var foo = "a valuable value"; console.log('compiling' + foo); return function (scope, element, attrs) { console.log('linking:' + foo); } } } }); you might also want to read about the order of execution of compile-link @joshdavidmiller said that given: <div directive1> <div directive2> <!-- ... --> &l

Categories : Angularjs

Leaflet load data and edit feature properties on mouse click
You'r using the same event name 'e' on both Click and success functions. Try to change one of them. ie function onClick(e) { var status = e.target.feature.properties.ACCESS; $.ajax({ url: "http://127.0.0.1:8080/?&u=x&p="+e.target.feature.properties.ID_PARCELL, dataType: 'jsonp', type: 'GET', success: function(data, evt) { status = data.status; e.target.feature.properties.ACCESS = data.status; e.target.bindPopup("Owner: <b>"+ data.status +"</b>").openPopup(); }, error: function(data){console.log(data)} }); e.target.feature.properties.ACCESS = status; map.fitBounds(e.target.getBounds()); } now you can change the initial event 'e' properties when the resu

Categories : Javascript

How to pass additional data to the callback when we pass Guid object as user state?
Create method overloading [Not Tested] void by_server_AddFriendCompleted(int user,int friend, Guid NGuid, object sender, AsyncCompletedEventArgs e) { //I want soemthing like e.Parameter ? , like we use AsyncState in sockets // ex : Myperopetyclass c = e.Parameter , this is what i want if (e.Error != null) //error }

Categories : C#

angularjs pass select option
ngModel holds the value of the selected option. So remove the value attribute from the select tag. Assuming the model to be as below $scope.lines = [ { name:"1" }, { name:"2" }, { name:"3" } ]; You can change the ng-options to below to specify the values as well: <select ng-model="record.Line" ng-options="l.name as l.name for l in lines" />

Categories : Javascript

AngularJS pass requestVerificationToken to a service
sadly, the easiest way is to include jquery.js into your project before angular.js, then do this: headers: { 'X-XSRF-Token': angular.element('input[name="__RequestVerificationToken"]') }

Categories : Angularjs

How to pass object between directives AngularJS?
Quote from documenation: The controller is instantiated before the pre-linking phase and it is shared with other directives (see require attribute). This allows the directives to communicate with each other and augment each other's behavior. This means that to share data between two directives on the same object or it's children, you'll need to expose foo inside directive A controller, injected with require option in directive B. The directives would look like this: .directive("dirA", function () { return { controller: function ($scope, $element, $attrs) { }, link: function ($scope, $element, $attrs, controller) { controller.foo = $attrs.dirA; } } }) .directive("dirB", function () { return { link: function ($sco

Categories : Javascript

Variable won't pass over as an argument in AngularJS
Try removing the {{}} in your function call. They aren't required. Not sure why it would still find some of the vars and not others, but in my plunker when I removed them, things started working.

Categories : Forms

AngularJS: How can I pass in the ID to a show action?
App.controller 'LeaderboardsCtrl', ['$scope', 'Leaderboard', ($scope, Leaderboard) -> $scope.selectedLeaderboard = Leaderboard.query({id: 'count-receiver'}) ] Just have to pass the ID to the service as above.

Categories : Ruby On Rails

AngularJS - pass callback from view?
In angular, the preferred way of doing DOM manipulation is to use directives... or to bind your view logic with directives like ng-show or ng-hide Just create a directive to wrap your modal window with, or use angular ui bootstrap's $dialog service.. which is an excellent one.

Categories : Jquery

How can I pass params with AngularJS $resource.query?
Below is the sample code: angular.module('phonecatServices', ['ngResource']). factory('Phone', function($resource){ return $resource('phones/:phoneId.json', {}, { query: {method:'GET', params:{phoneId:'phones'}, isArray:true} }); });

Categories : Javascript

how to pass an object to a directive template in angularjs?
The problem is that you add opts property to scope in the post-linking function, which will be called after modal directive's linking function, so the modal directive will never get those options. The solution is to move scope.opts = ... to pre-linking function: directive('update', function() { return { ... compile: function() { return { pre: function(scope, elm, attr){ ... scope.opts = { backdropFade: true, dialogFade: true }; } }; } } } http://plnkr.co/edit/iZaEiM?p=preview

Categories : Angularjs

Angularjs $resource - cannot pass array as one of the parameters
I created a plunkr for this one here. You are right, the resource service won't do what you want it to do.. at least I couldn't get it to. The way I was able to get it to work was by leveraging the $http service and building up my querystring with comma delimited values attached to the param 'status'. The result is a URI in the form: http://run.plnkr.co/someUrl?status=One,Two,Three On your API side, you can interpret the comma delimited arguments as elements with indexes. The basic build up in the code is something like this: var statusValues = ["One", "Two", "Three"]; var queryParams = "status="; for (var i=0;i<statusValues.length;i++){ queryParams += statusValues[i]; if (i != statusValues.length-1){ queryParams += ","; } } $http.get('/someUrl?' + queryParams).success(s

Categories : Angularjs

How to pass ampersand (&) to AngularJS resource parameter
So, I hate giving this kind of answer because I haven't actually done this myself, but have you looked into angular's http request interceptors? http://docs.angularjs.org/api/ng.$http

Categories : Javascript

AngularJS - Pass variable from a controller & update from directive
Shortly: bind to objects instead text values. Longer: see your forked Plnkr http://plnkr.co/edit/wzfwQI See comments which starts from "Changes:" in script.js and dynamicTextFields-template.html

Categories : Angularjs

How to pass a JavaScript object already on the page in to an AngularJS template
You need to make a couple of changes. Normally ng-model is used on inputs, but in your case we can use it as a marker to link angular world with non-angular world. <div ng-app="plunker" ng-model="currentRecord" ng-show="currentRecord"> {{currentRecord.FirstName}} - {{currentRecord.Surname}} </div> ng-model only binds to a javascript object on the current scope, so if you need to access properties from it you need to reference it directly. Updating the model from an external(not angular) source function myExternalFunction() { //external code // we need to get the element and wrap it in an angular element var $element = angular.element('[ng-model="currentRecord"]'); var scope = $element.scope(); //the ngModel controller will have the correct apis va

Categories : Javascript

AngularJS: How to pass values from Controller to Service Method?
One way of doing it is to inject the service into your controller: angular.controller('controllerName', ['$scope', 'Transaction', function($scope, transactionService) { ... } ]); Then you can access an instance of your service through the transactionService parameter. EDIT check out this fiddle Tell me if this is close enough to what you are trying to do

Categories : Javascript

AngularJS pass model to controller in live update
Most definitely you can. Just define the function in the same controller. For instance Controller: app.controller('myCtrl', function($scope) { $scope.increment = function() { return $scope.myModel; } }); HTML <div data-ng-controller='myController'> <input data-ng-model='myModel'> <p>{{increment()}}</p> </div> That returns the exact same thing as {{myModel}}

Categories : Javascript

angularjs - pass selected object's other properties on ng-change
Instead of passing in a property, you can pass the selected object into the function like this <select ng-model="campaign" ng-options="c.name for c in campaigns" ng-change="search2(campaign)"> Working Demo

Categories : Angularjs

How can I pass multiple parameters separated with a ? and & using AngularJS $resource?
Just add query parameters to the object parameter, i.e.: getEntity: function (entityType, entityId) { var deferred = $q.defer(); EntityResource.getEntity({ entityType: entityType, entityId: entityId, subjectId:12, contentTypeId:23 }, function (resp) { deferred.resolve(resp); } ); return deferred.promise; } Look at the parameters section in the AngularJS documentation for an explanation.

Categories : Angularjs

How to pass values from text area to table using AngularJS
Change ng_model = "letters" to ng-model = "letters". And letters should be an array instead of string. You have to split the input to list of strings. $scope.arrangelist = function() { var letterplits; letterplits = $('#letterlist').val().split(' '); $scope.letters = letterplits; return $('#arrangelist').modal('show'); }

Categories : Javascript

How to pass Rails current_user to AngularJS factory API call?
The user should never be sent from the client. You should never trust the client. Your rails app should have a session, and you should store the current user somewhere in the session. (Session is a hash, if you are doing it manually just use a sensible key to store the current user's ID). You do it on logging in, and just retrieve it afterwards. class ApplicationController < ActionController::Base attr_accessor :current_user before_filter :load_current_user # ... private def load_current_user self.current_user = User.find(session[:user_id]) end end And in your controller: def usersubmission @submissions = current_user.submissions @submission = @submissions.find(params[:id]) render json: @submission end If you use Devise or similar it's much easier an

Categories : Javascript

angularjs directive call function specified in attribute and pass an argument to it
Not knowing exactly what you want to do... but still here's a possible solution. Create a scope with a '&'-property in the local scope. It "provides a way to execute an expression in the context of the parent scope" (see the directive documentation for details). I also noticed that you used a shorthand linking function and shoved in object attributes in there. You can't do that. It is more clear (imho) to just return the directive-definition object. See my code below. Here's a code sample and a fiddle. <div ng-app="myApp"> <div ng-controller="myController"> <div my-method='theMethodToBeCalled'>Click me</div> </div> </div> <script> var app = angular.module('myApp',[]); app.directive("myMethod",function($parse) { var direc

Categories : Angularjs

Safe to pass current $scope from controller to angularjs service function
I would not pass the scope. Instead, I would explicitly, in your controller, hook up the unsubscribe. From http://odetocode.com/blogs/scott/archive/2013/07/16/angularjs-listening-for-destroy.aspx : $scope.$on("$destroy", function() { if (timer) { $timeout.cancel(timer); } }); I think having this done explicitly is not as magical, and easier to follow the logic. I think the service would be doing too much if it were to also unsubscribe. What if a controller wants to unsubscribe early? However, if you do have a very specific use case that's used everywhere, it would be fine to pass the scope in. The amount of time the service needs the scope is very small, basically when the controller first executes so that the service can listen to the $destroy event.

Categories : Angularjs

AngularJS: loop POST requests and pass each index into related response
This will do the trick: var params = [1, 2, 3], url, i, done = {}; for (i in params) { (function(p) { url = '/dir/'+ params[p]; $http.post(url, {"some_request": "not important"}). success(function(response) { done[params[p]] = 'successful'; }); })(i); } Another option is closure.

Categories : Javascript

Symfony 2 forms - pass data to select without data class (no entity)
Check the answer on Symfony 2 - how to pass data to formBuilder? for the techinque to pass values to a FormType class using the constructor.

Categories : PHP

Showing/Hiding a div based on data, without loading non-displayed data in AngularJS
What I'd do is add a method to your controller for this: $scope.getImages = function () { // add the logic to get the correct array here }; Then just use that in the view, e.g. <div ng-repeat="image in getImages()" /> Here's an example jsfiddle.

Categories : Javascript

Can anyone provide an example of an angularjs set-up that polls for data and updates the UI when data is received?
I have written this example : http://jsfiddle.net/rishabh/Kuewm/ You can have 2 way data-binding using '=' in directive scope when declaring hash. scope : { value : '=' // '=' indicates 2 way binding } Now you need to update the data in your controller for each chart independently and they will get updated in your view/directive. Now you can poll your service using $timeout like this :- $scope.chartValue = /*service call to init */; var poll = function() { $timeout(function() { /* service call to update chartValue */ poll(); }, 1000); }; poll(); This will update your chartValue after 1000 millisec. You can use different values for different charts. Edit : This is the fiddle http://jsfiddle.net/rishabh/76sKy/ You can just pass the value an

Categories : Javascript

Three.js + leaflet = 3D maps?
There is something called F4 Map, but there is not much information about this project. Check OSM wiki for some details. Example of map: Moscow

Categories : Javascript

Bootstrap row over leaflet
You can put them in a common container, and absolutely position the row you want to overlay the map. demo (with Leaflet) <div class="container-fluid"> <div class="mapbox"> <div class="row-fluid some" id="map"> <img src="//placehold.it/600x400"> </div> <div class="row-fluid overlay"> <div class="span1"> <button class="btn btn-primary">Button</button> </div> <div class="span2"> <button class="btn">Button</button> </div> </div> </div> </div> .mapbox { position: relative; } .mapbox .overlay { position: absolute; top: 0; left: 0; z-index

Categories : Javascript

R, GeoJSON and Leaflet
I ended up solving this question. What I basically did was basically join the data.2 df to the shape file: (shape2@data<-join(shape2@data,data.2) and then using rgdal package to writeOGR in JSON format (using JSON driver) with the *.js extension. I hope this helps others.

Categories : Json

How to put buttons on the leaflet map
I hope i understood your question right. You want to show three buttons inside the map and map should have rounded corners as well as the buttons should also have rounded corners. Hope this helps. Try this: HTML: <div class="span9" style="height:100%"> <div id="map"> <div style="padding-left: 10px;padding-right: 10px; position:absolute; bottom:-10px; width:100%;"> <input type="button" id="Btn1" value="Btn1" onclick="" class="btnStyle span3" /> <input type="button" id="Btn2" value="Btn2" onclick="SaveRoutes()" class="btnStyle span3" /> <input type="button" id="Btn3" value="Btn3" onclick="editRoutes()" class="btnStyle span3" /> </div> </div> <span id="studentsCount" class="

Categories : Javascript

Javascript leaflet function
If indiaLayer is a TileLayer, you should use indiaLayer.setOpacity(.8). If it's a Path (or an object that extends a path, eg. Circle), use indiaLayer.setStyle({opacity:.8}).

Categories : Javascript

Fixed image over Leaflet map
What if, instead of sticking a mask over the map, you put the map inside a div with border-radius:50%; overflow:hidden? I've never worked with Leaflet, though, so for all I know it won't work right under those conditions.

Categories : Javascript

Leaflet - Map is not getting center aligned
Map canvas' position and size should be fixed before map created. Hide/show <div>s first, then create map. Change order of createMap(); and $("#map").show();$("#list").hide();. fiddle: http://jsfiddle.net/e6y5k/

Categories : Jquery

Leaflet: add same layer to two different maps
As geocodezip mentioned in a comment, adding a polyline to a map sets the polyline object's this._map instance variable. Therefore, there is no way to have the object rendered on both maps with the way in which it is currently implemented. You can view the relevant source code here.

Categories : Javascript

Leaflet JS - Country Boundaries
This has nothing to do with leaflet. The lines are drawn by your tile provider. Change the source of the tiles to fit your needs. Cloudmade Mapbox

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.