Dongsan
Forum Replies Created
-
Forum: Plugins
In reply to: [GEO my WP] Geo My WP in Chinaand what would be the highest version with Bing map support?
Perfect. Thank you!
Forum: Plugins
In reply to: [Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps)] jsonpNot sure how I did it, and why it is working, but I managed to get it working. The biggest fault I made was that I used wp_remote_post() to retrieve the result set. I changed the codes as below, and now it’s working. Just in case there are other silly beginners like myself, here’s the code I have:
function jsonp_decode($jsonp, $assoc = false) { if($jsonp[0] !== '[' && $jsonp[0] !== '{') { $jsonp = substr($jsonp, strpos($jsonp, '(')); } $jsonp = json_decode(trim($jsonp,'();'), $assoc); $jsonp = $jsonp->data[0]; return $jsonp; } $jsonp = $response['body']; $data = jsonp_decode( $jsonp ); echo "ID = ".$data->id; echo "Markername = ".$data->markername; echo "layer = ".$data->layer;
Forum: Plugins
In reply to: [Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps)] jsonpThank you and sorry for bugging you with this simple problem, but I’m not a programmer nor in a tech-side. Please understand.
I tried again with the codes you provided, but still no fruits.
print_r($data) prints nothing, and echo $data[‘id’] prints nothing, either.
Giving it a second glance, I guess this is because the response I get from the query is a bit different from what is described in https://www.mapsmarker.com/docs/api-tutorials/web-api/#response.
Under https://www.mapsmarker.com/docs/api-tutorials/web-api/#response, it is described that the response is as below;
jsonp( { success: true, searchkey: "markername", .... - data: [ - { id: "1", markername: "test2", .... }, + { ... }, .... ] } )
However, the response I actually get is as below;
Array ( [headers] => Array ( [date] => Mon, 28 Apr 2014 11:41:09 GMT [server] => Apache ....... [content-type] => application/json; charset=utf-8 ) [body] => jsonp({ "success":true, "searchkey":"markername", "searchvalue":"dongsan", "searchresults":1, "message":"Search completed - showing 1 results below", "data": [ {"id":"68", "markername":"dongsan", ....... }]}); [response] => Array ( [code] => 200 [message] => OK ) [cookies] => Array ( [0] => WP_Http_Cookie Object ( [name] => qtrans_cookie_test [value] => qTranslate Cookie Test [expires] => [path] => /wordpress/ [domain] => 127.0.0.1 ) ) [filename] => )
So, I get not only jsonp({...}) but also get
Array(
[headers]=>Array()
[body]=>jsonp()
[response]=>Array()
[cookies]=>Array()
[filename]=>
)Could this be the reason of the problem?
Forum: Plugins
In reply to: [Leaflet Maps Marker (Google Maps, OpenStreetMap, Bing Maps)] jsonpThank you Robert for the reply. The thing is, I’ve already found that code in google and tried. Printing $data (echo $data;) yields null, and nothing is printed by $data->id. Really at a loss what I have done wrong…
Also, when displaying non-English feeds, it displays broken characters such as “2014 年 3 月 28 日,北京——微软公&#… read more”
Even if you don’t read Chinese, &# is obviously something wrong.