google map api no display laravel 5.4 - php

Why does my google map doesn't display anything ? I've tried other techniques but still it wont show up ?
the api key was already applied .
var map = new google.maps.Map(document.getElementById('map-canvas'),{
center:{
lat:10.2969,
lng:123.8887
},
zoom:15
});
This is the html file
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Address:</label>
<input type="text" name="address" id="searchmap" autocomplete="off">
</div>
<div class="form-group">
<label class="control-label">lat:</label>
<input type="text" name="lat" id="lat" autocomplete="off">
</div>
<div class="form-group">
<label class="control-label">lng:</label>
<input type="text" name="lng" id="lng" autocomplete="off">
</div>
<div class="form-group">
<div id="map-canvas">
</div>
</div>
</div>

Please make sure the google maps JS is included properly before you call it in javascript.
The google map is there but its not visible, please add hight and width:
<div id="map-canvas" style="width:300%;height:300px;"></div>

To specify the size of the div * element that includes the map, set the map height explicitly at all times:
#map { height: 100px; width: 50%; }
After further investigation, it was discovered that Google modified their business model on June 22, 2018. Since each API has its own unique billing, each API must be activated separately. The following APIs must be enabled in order for geocoding on Google Maps to function properly.
JavaScript API for maps
Directional Assistance
Service for Geocoding
Service for Distance Matrix
Access Service
Locations Library
Unfortunately, it doesn't appear like the Google Console API Manager is functioning properly. They won't appear when you search for an API other than the Maps JavaScript API.
You need to: to access them.
Access the project dashboard.
Then, select "Go to APIS overview."
Toggle "ENABLE APIS AND SERVICES" on.
You may now view the API options.
Do a Google Maps JavaScript API search (Under Google Maps APIs). Clicking on it will reveal an Enable button. To activate API, click.
Read more on-> Blog about google map errors

Related

How to Allow only Valid Gmail users sign up in my PHP Laravel website?

I have this my sign up form in my php Laravel site which I think hackers and robots are making unnecessary sign-ups. But now, I want to allow only Valid Gmail users to create an account. I have configured this form but users with unknown mails are able to sign up. I'm a newbie in php Laravel codes. Someone should please help me configure this to achieve the goal. Thanks in advance. See form bellow.
#csrf
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="{{__('Full Name')}}">
</div>
<div class="form-group">
<input type="text" name="username" class="form-control" placeholder="{{__('Username')}}">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="{{__('Gmail')}}">
</div>
<div class="form-group">
<input type="tel" name="tel" class="form-control" placeholder="{{__('WhatsApp Number')}}">
</div>
<div class="form-group">
<input type="text" name="gender" class="form-control" placeholder="{{__('Gender')}}">
</div>
<div class="form-group">
<input type="text" name="item" class="form-control" placeholder="{{__('What do you want to buy? Please type in your issues here')}}">
</div>
Laravel have great set of email validation tools. Here you can find some detail explanation: https://minuteoflaravel.com/validation/laravel-email-validation-be-aware-of-how-you-validate/
I think that will be enough to prevent most "hackers and robots" emails.
If you still want to accept "gmail.com" addresses only, then you can use, again, laravel ends-with validator:
'email' => ['ends_with:gmail.com', ...]
If you want to be sure that they are real emails then I suggest you implement laravel email verification
For more strict verification you can also use some external services like Mailgun email verification.
To stop bots from signing up, you can integrate a captcha service like ReCaptcha.
There are multiple packages which can help you reduce the amount of code to be written. Try having a look at laravel-recaptcha package on Github.

PHP Goutte. Change Select Field and capture Ajax Changes - Scraping BigCommerce

I am currently scraping a website running BigCommerce.
The variations have dropdown boxes, when the end user changes one of the select boxs the product information changes, the URL doesn't change.
When the select box is changed it POSTS the product ID and Variant ID, the page is then updated.
How can I mimic this select box change? I have tried to replicate the POST but I get a security token error as I suspect it's blocking cross domain scripting.
The page URL doesn't update so I can't even loop through pages, the form code is here
<div class="productView-options-wrap" data-product-option-change="" style="">
<div class="productView-options-inner">
<div class="form-field" data-product-attribute="set-select">
<label class="form-label form-label--alternate form-label--inlineSmall" for="attribute_select_176">
Color: <small>Required</small>
</label>
<select class="form-select form-select--small" name="attribute[176]" id="attribute_select_176" required="">
<option value="">View Options</option>
<option data-product-attribute-value="1126" value="1126">1 Standard (Most Popular)</option>
<option data-product-attribute-value="1127" value="1127">1 Standard</option>
</select>
</div>
</div>
</div>
<div class="form-field form-field--increments">
<label class="form-label form-label--alternate" for="qty[]">
Quantity:
</label>
<div class="form-increment" data-quantity-change="">
<input class="form-input form-input--incrementTotal" id="qty[]" name="qty[]" type="tel" value="1" data-quantity-min="1" data-quantity-max="0" min="1" pattern="[0-9]*" aria-live="polite">
</div>
</div>
<div class="form-action">
<input id="form-action-addToCart" data-wait-message="Adding to cart…" class="button button--primary" type="submit" value="Add to Cart">
</div>
The ajax being called is
var formData = {
"action": "add",
"attribute[176]": "1130",
"product_id": "931",
"qty[]": "1"
};
$.post('https://example.com/remote/v1/product-attributes/931', formData)
.done (showResult)
.fail(showError);
Thanks
There are 2 ways you can go about doing this.
You can use the V3 API, fetch all of the products, including their variants. You can use that data to hit the Product/Variant Options Endpoint, where you'll be able to read all the options metadata. You will be able to manually re-construct the HTML that way - although it's really not ideal.
An alternative would be to determine the SKU of each product variant, and append that as a query parameter to the product page URL.
If you include the SKU as a query parameter to the product page, it will render out the pre-selected option configurations.
I'm a bit confused as to what you're trying to accomplish with the scraped data? If you're going to be performing actions on it, you'll likely run into further CORS issues.
I ended up re-writing this using use Symfony DomCrawler and Guzzle
I was able to save the security token and submit with the ajax call and process the data that way. 700+ products in around 10 minutes.

Custom HTML for the search box used by the ListController behavior

I want to customize list searching behavior for backend panel.
I need to send keywords through ajax request, make a specific query and return/update this list.
At the moment search input works through Data attributes API.
<input placeholder="Search..." type="text" name="listToolbarSearch[term]" value="2" data-request="listToolbarSearch::onSubmit" data-track-input="" data-load-indicator="" data-load-indicator-opaque="" class="form-control icon search growable" autocomplete="off">
To be more exact I want to extend data-request="listToolbarSearch::onSubmit" function or make something like this and execute it through javascript ajax api on click event. I can't find this function in the framework(
This is fairly simple to do. Inside your List Controller configuration (config_list.yaml file), the toolbar search option will accept a partial name to use.
# Toolbar widget configuration
toolbar:
# Partial for toolbar buttons
buttons: list_toolbar
# Partial for toolbar search
search: my_search
Then inside your controller view directory you can use any search markup you like. For example, create a partial called _my_search.htm with these contents:
<div class="loading-indicator-container size-input-text">
<input
placeholder="Search for something"
type="text"
name="term"
value=""
data-request="onMyHandler"
data-track-input
data-load-indicator
data-load-indicator-opaque
class="form-control"
autocomplete="off" />
</div>

Link wizards in backend module in typo3-7

Help me i want to add link wizard in the backend module in front of the textfield without using TCA in typo3-7.6.9.
enter image description here
This could be possible as there has been a lot of changes regarding the JS and the form.
I quickly copied some code together which could be perfect for a base
<form name="editform">
<div class="form-wizards-element"><input type="text"
data-formengine-input-name="data[tx_news_domain_model_news][111][internalurl]"
value="" maxlength="255"
class="form-control t3js-clearable hasDefaultValue"/>
</div>
<div class="form-wizards-items">
<div class="btn-group"><a class="btn btn-default" href="#"
onclick="this.blur();vHWin=window.open('\/typo3\/index.php?route=%2Fwizard%2Flink%2Fbrowse\u0026token=970f35a8dc4409162cbcc22cbc0e6594074ac0b2\u0026P[params]=\u0026P[exampleImg]=\u0026P[table]=tx_news_domain_model_news\u0026P[uid]=111\u0026P[pid]=33\u0026P[field]=internalurl\u0026P[flexFormPath]=\u0026P[md5ID]=ID800c13a372\u0026P[returnUrl]=%2Ftypo3%2Findex.php%3Froute%3D%252Frecord%252Fedit%26token%3Db3d049b7b8bf49a7c89304b8ca24341be71120b1%26edit%5Btx_news_domain_model_news%5D%5B111%5D%3Dedit%26returnUrl%3D%252Ftypo3%252Findex.php%253FM%253Dweb_list%2526moduleToken%253D3dae7050436434ec90fe6376b230d7e43ded20c0%2526id%253D33%2526imagemode%253D1\u0026P[formName]=editform\u0026P[itemName]=data%5Btx_news_domain_model_news%5D%5B111%5D%5Binternalurl%5D\u0026P[hmac]=f1f3ba419c5ecf1bedce9656d521511cc0217a0a\u0026P[fieldChangeFunc][TBE_EDITOR_fieldChanged]=TBE_EDITOR.fieldChanged%28%27tx_news_domain_model_news%27%2C%27111%27%2C%27internalurl%27%2C%27data%5Btx_news_domain_model_news%5D%5B111%5D%5Binternalurl%5D%27%29%3B\u0026P[fieldChangeFunc][alert]=\u0026P[fieldChangeFuncHash]=c6a39ad17bdeac70cb33a3a0bccd0faa99e645c9'+'&P[currentValue]='+'&P[currentSelectedValues]=','popUpID800c13a372','height=600,width=800,status=0,menubar=0,scrollbars=1');vHWin.focus();return false;"><img
src="/typo3/sysext/backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif" alt="Link"
title="Link"/></a></div>
</div>
</form>
The popup opens and the value is written back as well to the form. However some more work needs to be done:
remove the not needed code
generate the correct token
Regarding the token, you can take a look at my news extension which uses e.g. that code
$token = FormProtectionFactory::get()->generateToken('moduleCall', 'web_NewsTxNewsM2');
I hope that helps

Google Map v3 Shortcode WP Plugin - Generate new Map over old? get Current Location?

I am using Google Map v3 Shortcode Plugin
Each post would have its own Google Map already (for ex: [map address="New York, USA" z="15" marker=”yes” ])
I want my users to type in their location (or not) and get direction - which should cause it to create a new Google Map with the direction route.
So I wrote:
<form class="searchform" action="<?php the_permalink(); ?>" method="post" >
<input type="text" value="<?php echo $address; ?>" name="directions_search" class="field s">
<input type="submit" value="Get Directions" name="submit" class="submit button"> </form>
<?php if(isset($_POST['directions_search'])){
$address = htmlspecialchars($_POST['directions_search']); echo do_shortcode('[map address="Queens, New York" z="15" marker=”yes” start= "'. $address .'" end="New York, USA"]'); } ?>
The new Google Map with direction route doesn't appear - I think because 2 maps cannot exist at the same time. How can I get the new map to appear?
If input is blank, how do I get the Current Location of the user? (for ex: in CityGuide wp theme or in regular Google Map)
Thanks!
Here's a quite good Documentation with a working example:
http://code.google.com/intl/en/apis/maps/documentation/javascript/directions.html#DirectionsRequests
I guess you need a Javascript which hooks (event: submit) into your Form (like jQuery) and does the Map Request.

Categories