Software Archive
Read-only legacy content
17060 Discussions

Help

Rahul_T_
Beginner
380 Views

Hello. I want to make an ap but im running into a few problems! the app basically allows user to add a marker with nee information to the map and can also display markers added by other users.  im in mainland china and cannot use google maps . do i need to upload data to a server or something so that a user can see markers added by other users? thanks for the support

 

 

0 Kudos
4 Replies
Chris_P_Intel
Employee
380 Views

do i need to upload data to a server or something so that a user can see markers added by other users?

Yes.   Do you know how to program this sort of thing? There is not only the backend code for receiving the submitted data and returning the consolidated data to a user, there is also the authorization/authentication for both tasks. If you don't know how to set this sort of thing up, you might be able to use Kinvey or Parse as a backend.  

0 Kudos
Rahul_T_
Beginner
380 Views

Ok. Actually I am an absolute beginner so no I don not know how to code the backend services

I found a walk around, using baidu lbs cloud api instead.
For now, I already have a location, and a way to collect the location data from cloud. Can you help to implement the code?
I ned to use the HTTP GET method.
I tried this 

<body>
<form id="myForm">
  <label for="myName">Send me your name:</label>
  <input type="button" value="Send Me!" onclick="httpGet()">
</form>
    <p>Hello, Intel XDK!</p>
<script>
    
var theUrl = 'http://api.map.baidu.com/geodata/v3/poi/list' + '?' + 'geotable_id=122134' + '&' + 'ak=GzieZbcFuthYfO2XP3rH0U0k';  
    function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
    </script>

but nothing happens. I checked the link. The method works well using a http requester tool
results:

GET http://api.map.baidu.com/geodata/v3/poi/list? geotable_id=122134&ak=GzieZbcFuthYfO2XP3rH0U0k

 -- response --
200 OK
Cache-Control:  max-age=86400
Content-Encoding:  gzip
Content-Length:  262
Content-Type:  text/javascript; charset=UTF-8
Date:  Wed, 07 Oct 2015 03:22:59 GMT
Error-Code:  0
Expires:  Thu, 08 Oct 2015 03:22:59 GMT
Http_x_bd_logid:  4088454063
Http_x_bd_logid64:  17671372987513246706
Http_x_bd_product:  map
Http_x_bd_subsys:  apimap
Hulu-Id:  0
Server:  Apache
Vary:  Accept-Encoding

{"status":0,"size":1,"total":1,"pois":[{"title":"xx","location":[113.340488,23.192065],"city":"\u5e7f\u5dde\u5e02","create_time":"2015-10-07 09:22:34","geotable_id":122134,"address":"\u5e7f\u4e1c\u7701\u5e7f\u5dde\u5e02\u767d\u4e91\u533a\u6843\u674e\u8def","province":"\u5e7f\u4e1c\u7701","district":"\u767d\u4e91\u533a","city_id":257,"id":1456828858}],"message":"\u6210\u529f"}

I need to get this response json in xdi so that I can use the value of location to plot it on a map
Thanks for the support

 

0 Kudos
Rahul_T_
Beginner
380 Views

I modified the code

 

function get(){  
    var url = 'http://api.map.baidu.com/geodata/v3/poi/list?geotable_id=122134&ak=GzieZbcFuthYfO2XP3rH0U0k';  

        var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        var myArr = JSON.parse(xmlhttp.response);
        alert(myArr);
    }
}
xmlhttp.open("GET", url, true);

xmlhttp.send();


}

However i keep getting cross-origin request blocked.

I am trying to implement xmlhttp.setRequestHeader("Access-Control-Allow-Origin", "*");      , but I do no know how to

0 Kudos
PaulF_IntelCorp
Employee
380 Views

Rahul, we don't have the resources to fix code or teach how to write code, sorry. There are many resources out there for learning about how to write server code and JavaScript and HTML5 code. In particular:

Some useful books are:

  • Pro HTML5 Programming, by Peter Lubbers
  • JavaScript: The Good Parts, by Douglas Crockford
  • CSS: The Missing Manual, by David McFarland
0 Kudos
Reply