I have an app developed using MeteorJs and I am trying to include googleMaps autocompletion using this package
https://github.com/jshimko/meteor-geocomplete
I want to have autocompletion in two views one is the landing page which has a simple input field autocompletion field only and the other is a submit_property view which has an autocomplete + map input fields, the problem is that I have followed all the instructions available for implementing autocompletion but their seems to be something wrong with my code, due to the fact that auto-completion does not appear in my inputs.
Landing page HTML:
<template name="layoutLanding">
<header>
<title>Real Estate</title>
<link rel="stylesheet" type="text/css" class="" href="/css/bootstrap.css">
</header>
<main>
<div id="Header">
<div class="wrapper">
</div>
</div>
<div id="bg">
<img src="/img/48.jpg" class="big"/>
</div>
<div id="Content" class="wrapper">
<div class="countdown styled"><img src="/img/logo.png"/></div><br/>
<!-- <h2 class="intro">Our website is under construction. Stay tuned for something amazing!. Subscribe to be notified.</h2> -->
<div id="subscribe">
<form action="" method="post" onsubmit="">
<p>
<button type="button" id="select">Acheter</button>
<button type="button" id="select1">Louer</button>
</p>
<!-- Using 2 traingles to achieve border outline :) -->
<i id="triangle_down1" style="display: none"><i></i></i>
<i id="triangle_down" style="display: none"><i></i></i><br/>
<!--Louer triangles -->
<i id="triangle_down2" style="display: none"><i></i></i>
<i id="triangle_down3" style="display: none"><i></i></i><br/>
<div></div>
<p><input name="" placeholder="Entrer une ville au Maroc" type="text" id="landing-entry"/>
<input type="submit" id="main" value="Search"/>
</p>
</form>
</div>
</div>
<div id="overlay"></div>
</main>
</template>
Landing page JS
Template.layoutLanding.onRendered(function() {
this.autorun(function(){
if(GoogleMaps.loaded()){
$('#landing-entry').geocomplete();
}
});
});
Submit_property HTML
<!-- This file is quite big so i have just included where the autocompletion needs to be -->
<div class="clearfix"></div>
<hr>
{{> afQuickField name="address" id="geocomplete" placeholder="Type in an address"}}
<input id="find" type="button" class="btn btn-primary" value="Find Address" />
<div class="map_canvas"></div>
<hr>
submit_property JS
Template.submit_property.onRendered(function() {
this.autorun(function(){
if(GoogleMaps.loaded()){
$('#geocomplete').geocomplete({
map: ".map_canvas",
details: "form",
types: ["geocode", "establishment"],
});
}
});
});
Template.submit_property.events({
'click #find': function(){
$('#geocomplete').trigger('geocode');
}
});
It seems you forgot to include Google Maps API loading using GoogleMaps.load function:
if (Meteor.isClient) {
// Load the Google Maps API on startup
Meteor.startup(() => {
GoogleMaps.load({
key: '',
libraries: 'places'
});
});
Template.layoutLanding.onRendered(function () {
this.autorun(function () {
if (GoogleMaps.loaded()) {
$('#landing-entry').geocomplete();
}
});
});
}
meteor-geocomplete package utilizes Google Maps Places API
meteor-geocomplete package has a dependency to
meteor-google-maps package which in turn is used for Google Maps
API loading.
Related
I have the following drop zone js and have a file input hidden with an asp-for tag which should map to my viewmodel. However there is nothing being mapped. The controller accepts a parameter List FormFiles.
<form method="post" asp-action="Index" asp-controller="Customer" class="js-step-form js-validate" enctype="multipart/form-data"
data-hs-step-form-options='{
"progressSelector": "#validationFormProgress",
"stepsSelector": "#validationFormContent",
"endSelector": "#validationFormFinishBtn",
"isValidate": true
}'>
<!-- Step -->
<!-- End Step -->
<!-- Content Step Form -->
<div id="validationFormContent">
<div id="validationFormAccount" class="active">
<div class="row">
<div class="col-sm-6">
<!-- Form Group -->
<div class="form-group js-form-message mb-3">
<label class="input-label">Loyality Spend</label>
<input id="LoyalitySpendTextBox" type="text" class="form-control stringValidation" required
data-msg="Please enter Loyality Spend." placeholder="Loyality Spend" aria-label="Current Value" value="#Model.Customer.LoyaltySpend" asp-for="#Model.Customer.LoyaltySpend">
</div>
<!-- End Form Group -->
</div>
<div class="col-sm-6">
<!-- Form Group -->
<div class="form-group mb-3">
<label class="input-label">Documents</label>
<!-- Dropzone -->
<div id="attachFilesLabel" class="js-dropzone dropzone-custom custom-file-boxed">
<div class="dz-message dz-filename">
<img class="avatar avatar-xl avatar-4by3 mb-3" src="~/front-dashboard-v1.1/src/assets/svg/illustrations/browse.svg" alt="Image Description">
<h5>Drag and drop your file here</h5>
<p class="mb-2">or</p>
<span class="btn btn-sm btn-white" id="chose_files_btn" onclick="doOpen(event)">
Browse File
<input type="file" asp-for="#Model.FormFiles" id="File" name="File" size="1" style="display: none" />
</span>
</div>
</div>
<!-- End Dropzone -->
</div>
<!-- End Form Group -->
</div>
</div>
</div>
</form>
If you want to bind data with name FormFiles,you can use paramName of Dropzone.And if you want to upload files when button click,try to use autoProcessQueue: false,,and in button click event add e.preventDefault();wrapperThis.processQueue();.If you want to delete files,you need to add addRemoveLinks: true, and use removedfile. Here is a demo.
View:
<form asp-action="Upload" asp-antiforgery="false"
class="dropzone" id="myAwesomeDropzone" enctype="multipart/form-data">
<div class="fallback">
<input asp-for="FormFiles" type="file" multiple />
</div>
js:
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.css"/>
<script>
function myParamName() {
return "FormFiles";
}
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
paramName: myParamName, // The name that will be used to transfer the file
uploadMultiple: true,
parallelUploads: 100,
addRemoveLinks: true,
removedfile: function (file) {
file.previewElement.remove();
},
init: function () {
console.log("active");
var wrapperThis = this;
$("#submit").click(function (e) {
e.preventDefault();
wrapperThis.processQueue();
});
},
accept: function (file, done) {
done();
}
};
</script>
action:
[HttpPost]
public IActionResult Upload(List<IFormFile> FormFiles)
{
return Ok();
}
result:
I have this html code
<head>
<link rel="stylesheet" href="./Depd/bootstrap.min.css">
</head>
<body>
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="inputGroupFile04" aria-describedby="inputGroupFileAddon04">
<label class="custom-file-label" for="inputGroupFile04">Choose file</label>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
</div>
</div>
<script src="./Depd/jquery.slim.min.js">
</script>
<script src="./Depd/popper.min.js"></script>
<script src="./Depd/bootstrap.min.js"></script>
</body>
When I run and try to upload a file by clicking browse and select a file i want to change the label text to the name of the file I uploaded how can I achieve that?
I'm using bootstrap. If you don't use bootstrap and use normal html it works in default way and shows the file name. But I have to use bootstrap here. So, please suggest a solution that goes with bootstrap.
You're going to need to use some JavaScript for this. I'll walk you through the steps: First detect when a file gets uploaded, then get the file name and update the label contents with the filename. Below is a brief example.
let input = document.getElementById("inputGroupFile04");
let label = document.querySelector("label[for='inputGroupFile04']");
input.addEventListener("change", e => {
label.innerText = input.value.split(`C:\\fakepath\\`)[1];
});
<head>
<link rel="stylesheet" href="./Depd/bootstrap.min.css">
</head>
<body>
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="inputGroupFile04" aria-describedby="inputGroupFileAddon04">
<label class="custom-file-label" for="inputGroupFile04">Choose file</label>
</div>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
</div>
</div>
<script src="./Depd/jquery.slim.min.js">
</script>
<script src="./Depd/popper.min.js"></script>
<script src="./Depd/bootstrap.min.js"></script>
</body>
If you require any more clarification please don't hesitate to ask.
I tried putting a div tag around the whole template and styling it with css like
<div ng-style="{'background-image': 'url(/images/food.png)', 'background-repeat': 'repeat-y'}">
<img src="/images/final.png" class="brandImg center-block">
<h3 class="text-center"> Please Enter your Registered Mobile Number to Login</h3>
<form novalidate name="CSloginForm" ng-submit="loginCustomer()" role="form" class="csLoginForm col-xs-6 col-xs-offset-3">
<div class="form-group col-xs-offset-1">
<label for="phno" style="font: 22px sans-serif;">Mobile No</label>
<input type="tel" name="phno" id="phno" style="margin-left: 60px; width: 300px; margin-top: 50px; margin-bottom: 20px" class="phInput" ng-maxlength="10" ng-minlength="10" ng-model="csNumber" required />
</div>
<div class="form-actions">
<button type="submit" ng-disabled="CSloginForm.$invalid" class="btn btn-primary btn-lg col-xs-offset-9" ng-click="csLookUp()" style="margin-bottom: 10px">Start</button>
</div>
</form>
</div>
but this only puts background in a header part of the Page not the whole page?
You can use $rootScope for this. Object in the root scope are propagated to all child scopes.
angular.module('app').run(function($rootScope) {
$rootScope.app = { background-image: 'url(/images/default.png)' };
});
Now in your base HTML template you add the background to the body (not a div).
<html ng-app="app">
<head>
...
</head>
<body ng-style="{'background-image': app.background, 'background-repeat': 'repeat-y'}">
...
</body>
Given that the view has a controller
<div ng-controller="PageCtrl">
..
</div>
You can access app and set the background from the controller
angular.module('app').controller('PageCtrl', function($scope) {
$scope.app.background = 'url(/images/food.png)';
});
You can set the background in a view without a controller using ng-init, but this is discouraged.
I have created simple audio apk. In this apk, I have added one option called "choose images" for the Play button in this option. I have an issue that chosen images from the gallery is not showing in the Play button. I have tried this code which is from the phonegap doc. But its not working for me. Below is the code for your reference, wherein I have selected the images.
May I know how to solve this solution. It will be very helpful to me.
<input id="mainplay" data-button="play" type="image" src="img/newplay.png" class="audiodata" id="imgData" alt="Submit" width="70" height="70" />
</div>
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
function onPhotoURISuccess(imageURI) {
var largeImage = document.getElementById('largeImage');
largeImage.style.display = 'block';
localStorage.setItem("imgData", imageURI);
$('#imgData').attr('src', imageURI);
largeImage.src ="data:image/jpeg;base64," + imageURI;
}
<div data-role="page" id="home">
<div class="ui-btn-right">
<a class="alignment ui-btn-active ui-state-persist" data-role="button" data-icon="gear" data-iconpos="notext"></a>
</div>
<div id="settings" style="display:none;">
Back<br><br>
<fieldset class="ui-field-contain">
<label for="Choose Audio">Choose Audio</label>
<select class="audioselect" name="selectaudio" id="selectaudio">
<option value="/android_asset/www/audio/Commercial DEMO - 15.mp3">Commercial DEMO</option><option value="/android_asset/www/audio/p1rj1s_-_rockGuitar.mp3">RockGuitar</option>
</select>
</fieldset><br>
<fieldset class="ui-field-contain">
<label for="Volume">Volume Control</label><br>
<span class="tooltip"></span> <!-- Tooltip -->
<div id="slider"></div> <!-- the Slider -->
<span class="volume"></span> <!-- Volume -->
</fieldset><br>
<fieldset>
<button data-inline="true" onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">Choose Photos</button>
<div style="display:none;"><img id="largeImage" src="" /></div> </fieldset><br>
</div>
<input id="mainplay" data-button="play" type="image" src="img/newplay.png" class="audiodata" id="imgData" alt="Submit" width="70" height="70" />
</div>
I don't see a reference to phonegap.js in your code.
You don't have a script tag around your JavaScript code.
You need an ondeviceready function and add these two lines of code;
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
Please read further on here and study the full example carefully.
I'm having 2 buttons to load 2 separate forms, events and offers. when a user clicks on a button i want to load the relevant html form and make the buttons disappear.
events loads events.html
offers loads offers.html
<div class="view_col">
<form id="form1" name="form_b" method="post" action="">
<input name="c_event" class="clr" type="button" value="event" />
<input name="c_offer" class="clr" type="button" value="offer" />
</form>
</div>
load the form to
<div id="form_body"> </div>
i want make sure that the buttons are disappear after the user has clicked.
Can someone give an idea how to do it?
You need to use $.load() to get the HTML from your external HTML pages. Try something like this:
HTML
<div class="view_col">
<form id="form1" name="form_b" method="post" action="">
<input name="c_event" class="clr" type="button" value="event" id="eventsBtn" />
<input name="c_offer" class="clr" type="button" value="offer" id="offersBtn" />
</form>
</div>
jQuery
$("#eventsBtn").on('click', function() {
$("#form_body").load('events_loads_events.html');
});
$("#offersBtn").on('click', function() {
$("#form_body").load('offers_loads_events.html');
});
More information on load();
If you use jQuery then this is quite easy:
$('#form1 input').on('click', function(event) {
var $target = $(event.target);
$('#form_body').load($target.data('url'));
$('#form1').hide();
})
You would have to change you html into this:
<div class="view_col">
<form id="form1" name="form_b" method="post" action="">
<input name="c_event" class="clr" type="button" value="event" data-url="http://www.path-to-your-form-html-for-this-button.com/"/>
<input name="c_offer" class="clr" type="button" value="offer" />
</div>