[SOLVED] Maps with http rest api

Hi is there a way to use the map plugin so my devices can send me their gps position using the http rest api? I’ve tried a few things but can’t get it working. The blynk example page has no details on maps

By http rest api i mean
request = “http://blynk-cloud.com/” + str(token) +"/update/" + str(pin) + “?value=” + str(value)

blynk page
http://docs.blynkapi.apiary.io/#reference/0/get-pin-value/get-pin-value

Sure it does.

The Map Widget just takes the provided coordinates and displays them on the Map App… how you get those coordinates into your sketch is up to you. Many methods could be used, including precoded, GPS module, or feeding that data via outside sources.

Thanks for the reply. Yeah I see how to do it with their library, my question is how to do it with the rest api. How would I format the url to send the data to their server

Use the GET (not PUT) as http://blynk-cloud.com/auth_token/update/pin?value=value

I think i am using the get. I really just need 1 example of how to put the gps data for the map in the format you mentioned “http://blynk-cloud.com/auth_token/update/pin?value=value

more in depth example of my code which doesn’t work:
pin = “V11”
value = str(“11,1,40.754129,-88.6964227,test”)
request = “http://blynk-cloud.com/” + str(token) +"/update/" + str(pin) + “?value=” + str(value)
callURL(request)

def callURL(getStr):
… proxy/headers stuff here
req = urllib2.Request(getStr, None, headers)
html = urllib2.urlopen(req).read()

Tested and working (didn’t bother with token but you should be ok with that):

# api.py 
from urllib2 import Request, urlopen
pin = "V11"
value = str("11,1,40.754129,-88.6964227,test")
request = Request('http://blynk-cloud.com/xxxxxxxxxxxxxxxxx/update/' + str(pin) +'?value=' + str(value))

response_body = urlopen(request).read()
print response_body

Test was sent to Terminal but you can send wherever you like, within reason.

right. i know that will display properly in a terminal. My question is how to get it to show correctly in the map widget, so whatever position is sent in shows up in the map.

Do you know the syntax for the Map widget?

Do you know how to manipulate the String received in Terminal or other widget?

  1. “Do you know the syntax for the Map widget?” No I don’t that’s the question, how do i format the data using the http rest api to get data to show up in the map widget.

  2. “Do you know how to manipulate the String received in Terminal or other widget?” I can manipulate the data going to blynk in whatever way is neccessary. So yes.

Python (you don’t need to send Vx in parameter as that can be handled by the Terminal widget:

# api.py  run as python api.py from console / terminal / dos prompt on a machine with Python

from urllib2 import Request, urlopen
pin = "V11"   # Terminal widget

mapPointer = 1
parameter = str(str(mapPointer) + ",30.123456,30.987654,Here")

token = str("xxxxxxx")  # token for project

request = Request('http://blynk-cloud.com/' + str(token) + '/update/' + str(pin) +'?value=' + str(parameter))

response_body = urlopen(request).read()
print response_body

In Terminal widget, after you have done the String manipulation, for a Map on V6 it is:

Blynk.virtualWrite(V6, point, String(latitude, 6), String(longitude, 6), MapPointName);

Screenshot of Terminal and Map

don’t know why, but that doesn’t work for me. I’m only using the rest api, so blynk says ‘device offline’ wonder if that affects the map widget.

To clarify, everything else works fine

Perhaps you should get your device online.

well i’m pushing data to the token. It’s updating every second, don’t know why the blynk app says its offline

@thefatmoop which MCU are you using or are you just trying to use the api without a MCU?

i’m not using a mcu on this

This is default behavior as Blynk was designed to work with real devices. Maybe someday we will fix that.

1 Like

yeah i’d encourage you to do so. Really i just want a scatter plot. I was planning to go through the trouble of doing a Cartesian -> lat/long converter, but since the map didn’t work i guess i can’t

Is this problem already resolved? Thanks for your work

Not in our roadmap right now.