Google Places API search inconsistent - google-places-api

Google Places API behaves unexpectedly for a specific type of search.
I thought that the API returns a list of all places that is related to a query when 'type' is not specified but that doesn't seem to be the case. I get different (non-overlapping) results for the requests below, using same query "bergamo8":
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=bergamo8&key=API_KEY
<PlaceSearchResponse>
<status>OK</status>
<result>
<name>Bergamo</name>
<type>locality</type>
<type>political</type>
<formatted_address>Bergamo, Province of Bergamo, Italy</formatted_address>
<geometry>
<location>
<lat>45.6982642</lat>
<lng>9.6772698</lng>
</location>
<viewport>
<southwest>
<lat>45.6625158</lat>
<lng>9.6205463</lng>
</southwest>
<northeast>
<lat>45.7238489</lat>
<lng>9.7136328</lng>
</northeast>
</viewport>
</geometry>
<icon>
https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png
</icon>
<reference>
CmRbAAAA8T_6nvUrkTUF85gJtkVtFdbUccfYlcxVOziiUZ_HAsWHdySDg8cdPKvQD2wMjMx2oPc17nn4R3YaQDXbKViVyxHHf1qgWVwJ3yUHGygud4hUnY9aADoHSH-8U1l3xdaNEhD_SrAbwT9WGEQIedHS67AQGhTowbrLa_4LvWMfYSekJlYzOVyj5w
</reference>
<id>89666d6c7fc59efec1788477617d124d59a254f9</id>
<photo>
<photo_reference>
CmRaAAAAAFWrmgCoXKoske2yxr9a6EkTDMlL59VTQ2bJ_SWzLxGT5itDjXLegV1Geliqilz70Ve3fekX9LUa46NcdVWPCKFGw8P1XniuDx8ZSyoNhObzrFTkgOI6TajtzqaOyG8fEhCnQYNCt4A19laWACC_c4OnGhQxg1rTA9mRBcgZlN_iMt4dViX6HQ
</photo_reference>
<width>2560</width>
<height>1536</height>
<html_attribution>
Barbara Grassi
</html_attribution>
</photo>
<place_id>ChIJc65ivBFRgUcR0aTlC4_LL9M</place_id>
</result>
</PlaceSearchResponse>
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=bergamo8&type=lodging&key=API_KEY
<PlaceSearchResponse>
<status>OK</status>
<result>
<name>Bergamo8</name>
<type>lodging</type>
<type>point_of_interest</type>
<type>establishment</type>
<formatted_address>
Piazza della Repubblica, 3, 24122 Bergamo BG, Italy
</formatted_address>
<geometry>
<location>
<lat>45.6979060</lat>
<lng>9.6674570</lng>
</location>
<viewport>
<southwest>
<lat>45.6965483</lat>
<lng>9.6660933</lng>
</southwest>
<northeast>
<lat>45.6992480</lat>
<lng>9.6687930</lng>
</northeast>
</viewport>
</geometry>
<rating>4.0</rating>
<icon>
https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png
</icon>
<reference>
CmRbAAAAciLhIMD6BUcnZrkiI3og5zkv8iufp0MXe1UJ48ZnBZgc37dyohrPK8SuBVIl9vtnMaeuqiS1rRUq1IcfoK9Y-DKQj17jsK0QttB-2Q5PICXtL23ZOFABZwPKFMCHvoGSEhC2tTX2oEUtdtvJJElkvA24GhRxoVbZjb2mIzhlLwzZYZKfvcTN3A
</reference>
<id>443bfff8822b1f589bffc27a4e4f9e3201e99200</id>
<opening_hours>
<open_now>true</open_now>
</opening_hours>
<photo>
<photo_reference>
CmRaAAAAW37hcFzSRR3TQWPggrDHh7g5nizXfCmtKuif8y-nX4_q6oQdt7GHNWe5YPOrrqcSfs_1a0opZHnFzV1QBBbh1RYNN4D41yTzM03VpGtIpamTNWY9Gyyv7oAi3p4r460SEhAAqvPQOxucRXoKwmmsTmE4GhQ3wybwAY9EmBKDd6uprFgHq_QiEA
</photo_reference>
<width>2048</width>
<height>1335</height>
<html_attribution>
Bergamo8
</html_attribution>
</photo>
<place_id>ChIJhfjVaxFRgUcRolpKS-72w8M</place_id>
</result>
</PlaceSearchResponse>
Does anyone know if this is a bug or if there is a way to retrieve all types of places related to a query?
Thanks!

Related

Outllook addin function getRegExMatches() is always returning null

I am trying to develop a outlook add-in that finds an expression with regex in the mail body, but the getRegExMatches() always give me null.
I didn't know how to do it so I tried the example in https://learn.microsoft.com/en-us/office/dev/add-ins/reference/objectmodel/requirement-set-1.5/office.context.mailbox.item?product=outlook&version=v1.5#getregexmatches--object
the code for the rules of the example are
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" FormType="Read" ItemType="Message" />
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="fruits" RegExValue="apple|banana|coconut" PropertyName="BodyAsPlaintext" IgnoreCase="true" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="veggies" RegExValue="tomato|onion|spinach|broccoli" PropertyName="BodyAsPlaintext" IgnoreCase="true" />
</Rule>
</Rule>
and in the javascript I can call this rule like this
var allMatches = Office.context.mailbox.item.getRegExMatches();
var fruits = allMatches.fruits;
var veggies = allMatches.veggies;
the var allMatches is the one that gives me a null, because of that the others 2 variables gives an error. This was supposed to give an array with strings, which this strings must be equals to the strings in the rules (like apple, banana, etc).
The regex rules should only work in the context of detected entities. You can read more about it here: https://learn.microsoft.com/en-us/outlook/add-ins/contextual-outlook-add-ins. Are you running your add-in from a detected entity as a contextual add-in? If not, then use Body.getAsync to get the body, and then try searching in the body with your regex.

Can't set a test license token in an Outlook addin

I'm trying to set a test license token in an Outlook add-in. According to the documentation, I have to set it in the SourceLocation in the manifest file:
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000?et=%3Cr%3E%0A%20%20%3..."/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
The problem is, when I try to get the URL query params, it won't work. window.location looks like this:
https://localhost:3000/?et=
Any idea why it's happening?
When I update the source location of the Action ShowTaskpane, it won't start the addin:
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="messageReadTaskPaneUrl" />
</Action>
...
<bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000?et=%3Cr%3E%0A%20%20%...">
If I set it like this, when I start the addin, it says:
Sorry, but we can't start this add-in because it isn't set up properly.
I use the following test token:
<r>
<t
aid="WA907006056"
pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}"
cid="32F3E7FC559F4F49"
did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}"
ts="30"
et="Trial"
ad="2012-01-12T21:58:13Z"
ed="2019-06-30T21:58:13Z"
sd="2012-01-12T00:00:00Z"
test="true"
te="2019-06-30T02:49:34Z" />
<d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d>
</r>
And use the following service to encode the url:
https://www.urlencoder.org/
The problem is with URL encoding. When encoding the token, you have to remove all the new lines. Otherwise, it will throw an error. So, before encoding, take the token...
<r>
<t
aid="WA907006056"
pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}"
cid="32F3E7FC559F4F49"
did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}"
ts="30"
et="Trial"
ad="2012-01-12T21:58:13Z"
ed="2019-06-30T21:58:13Z"
sd="2012-01-12T00:00:00Z"
test="true"
te="2019-06-30T02:49:34Z" />
<d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d>
</r>
and remove all the new lines like this:
<r> <t aid="WA907006056" pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}" cid="32F3E7FC559F4F49" did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}" ts="30" et="Trial" ad="2012-01-12T21:58:13Z" ed="2019-06-30T21:58:13Z" sd="2012-01-12T00:00:00Z" test="true" te="2019-06-30T02:49:34Z" /> <d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d> </r>
Finally encode it and add to all the source locations.

How to use Activity attribute android:showForAllUsers in Xamarin?

The attribute is not implemented in Xamarin. This mean I can't declare it as an attribute of my Activity Class like it should:
[Activity(Label = "#string/app_name", Theme = "#style/MainTheme.StopAlarm", LaunchMode = Android.Content.PM.LaunchMode.SingleTask, ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait, NoHistory = true)]
public class StopAlarmActivity : Activity
{
...
}
There's no ShowForAllUsers option.
The other option is to edit Properties => AndroidManifest.xml and add the activity manually like this:
<activity
android:name=".StopAlarmActivity"
android:label="#string/app_name"
android:theme="#style/MainTheme.StopAlarm"
android:showForAllUsers="true">
</activity>
But once I compile the final AndroidManifest.xml file contains two declarations, the manually added and the compiled one from the class declaration.
<activity android:name=".StopAlarmActivity" android:label="#string/app_name" android:theme="#style/MainTheme.StopAlarm" android:showForAllUsers="true"></activity>
<activity android:label="#string/app_name" android:launchMode="singleTask" android:noHistory="true" android:screenOrientation="portrait" android:theme="#style/MainTheme.StopAlarm" android:name="md5e24228758d0205525e724fe958bff865.StopAlarmActivity" />
That said, it looks like the only option is to edit the compiled AndroidManifest.xml file after each compilation. Which is a major breach for problems.
Any other way to accomplish it where I don't need to rely on remembering it every time I compile the app?
On your Activity attribute, applied a Name to avoid the MD5-based Java class auto-naming:
[Activity(Name = "com.sushihangover.MainActivity")]
In your manifest use the same fully-qualified name (no abbreviated dot notation) with the attributes you wish to apply to this activity:
<activity
android:name="com.sushihangover.MainActivity"
android:showForAllUsers="true"
android:icon="#mipmap/icon"
android:label="MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Note: All the attributes for this Activity need to be added within the manifest, not the Activity class attribute.
The final manifest entries will be merged correctly:
<activity android:name="com.sushihangover.MainActivity" android:showForAllUsers="true" android:icon="#mipmap/icon" android:label="MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Custom Statuses in Magento on history.phtml

I have created some custom statuses beyond the default Magento statuses.
When I grab an order to send to production, I set the status in Magento via the API. Problem is, if the order is set to one of these custom statuses, it doesn't show the order in the My Account Order History area for the customer.
What do I need to do to show these orders in the My Account Order History area, that have my custom statuses currently set?
For question sake, this status is called "New Status" and I have assigned it to the processing state.
Short answer... merge this with app/code/core/Mage/Sales/config.xml or (better) add this to a config.xml in your own local module. Modifying core files is frowned upon (but happens).
Change new_status to your status.
<config>
<global>
<sales>
<order>
<statuses>
<new_status translate="label">
<label>New Status</label>
</new_status>
</statuses>
<states>
<new_status translate="label">
<label>New Status</label>
<statuses>
<new_status default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</new_status>
</states>
</order>
</sales>
</global>
</config>
Long answer: See Mage_Sales_Block_Order_History specifically, the piece that grabs the order collection
$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
->setOrder('created_at', 'desc')
The second addFieldToFilter looks for order states within a set of "visible" states. Those set of states are pulled by Mage_Sales_Order_Config, and are set in the configuration. See above for the configuration changes. You can look in Mage_Sales_Order_Config and the function _getStates() to see how it pulls these from the configuration.
Suppose your custom order status is paymentsuccess in magento order_status table
<config>
<global>
<sales>
<order>
<statuses>
<paymentsuccess translate="label">
<label>Payment Successful</label>
</paymentsuccess>
</statuses>
<states>
<paymentsuccess translate="label">
<label>Payment Successful</label>
<statuses>
<paymentsuccess default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</paymentsuccess>
</states>
</order>
</sales>
</global>
</config>

Magento _getUrl call function is duplicating the url to my link

I use the function _getUrl to link the top link I created in my custom module, but for some reason it duplicates the URL. For example, say I want it to link me to:
www.localhost.com/magento/sapna/account/index
instead, it shows:
www.localhost.com/magento/http://index/www.localhost.com/magentosapna/account/index
Here is my function:
const ROUTE_FORM = 'sapna/account/index';
/**
* Retrieve goomer/breeder registariion url
*
* #return string
*/
public function getLoginUrl(){
return $this->_getUrl(self::ROUTE_FORM, $this->getLoginUrlParams());
}
i'm doing in module/Helper/Data.php and i use getUrl it does not work
I wrote this in the Data.php helper file. Can anyone help? I have been through this so many times, but I do not see what is wrong.
Check your customer.xml file for the following :
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer">
<label>Log In</label>
<url helper="customer/getLoginUrl"/>
<title>Log In</title>
<prepare/>
<urlParams/>
<position>100</position>
</action>
</reference>
<remove name="reorder"></remove>
</customer_logged_out>
/* Use <prepare/> instead of <prepare>true</prepare> */
worked for me...!

Resources