Map value integration

Hi Guys,

I am building a GPS tracker, facing issues with the maps integration on Blynk web as well as mobile app. I am able to view the GPS data on 2 virtual pins with dialog boxes however the data is not received by the Map Widget. Following is my code on the ESP32 device ( I have tried both functions separately and on V0 pin too)

Blynk.virtualWrite(V4, Index, latitude, longitude, “Location”);

and
WidgetMap myMap(V4);
int Index = 1;
double latitude = (gps.location.lat());
double longitude = (gps.location.lng());
myMap.location(Index, latitude, satellites, “Location”);

Please help, I am unable get the lat and lng value on the map widget but available on other virtual pins separately.

@srilalan hello. At the moment we have multiple issues with map widgets. First of all - mobile widget and web map widget works in different ways. So, for now, you can use either web or mobile, but not both. This is because these widgets were designed and made for different clients and they have different requirements.

So, to make the web map widget work you need to:

Blynk.virtualWrite(v4, lon, lat);

Please pay attention to the order. longitude goes first.

The mobile map widget is not working at the moment. We’ll fix it soon.

Hi Dmitriy,

Greetings, thanks for your swift reply.
Tracker is working now, with both web app and mobile app working simultaneously. Looks Superb! thanks.

I have almost finished moving my 2000+ line app to Blynk IOT but have come across an incompatibility with the Map widget that’s key to my device. The call I used in my legacy Blynk app is:

Blynk.virtualWrite(V7, markerNum, latI, lonI, pmLabel, newColor); // update marker position=GPS, label = sensor value, color=PMAQI value (marker color hack for iOS)

For Blynk IOT I am using what you suggest above, which seems to work as far as basically placing a marker on the map at the correct lat and lon:

Blynk.virtualWrite(V7, lonI, latI); // for Blynk IOT

Question: will we see the missing functions - number, label, color - added to Map? They really are key to making a commercial-looking (as Apple, Google or other moving map app would do) tracking app. Thanks for a superb new Blynk!

Here’s what my app looks like under old Blynk:

EDIT 1: Although the black marker appears to be drawn at the correct location on the Map, it doesn’t persist. That is, every time I make the Blynk.virtualWrite call it only moves the marker to the new location without leaving the previous marker to show the location of the last location (see image above.) Is this the intended function of the new Map widget or am I missing something? I seem to recall running into this with the old Blynk when I didn’t properly increment the “index” value. As there seems to be no such variable in the new Blynk (call is apparently Blynk.virtualWrite(V7, lonI, latI);, I am wondering if there is a similar problem with overwriting instead of persisting as is needed for a proper tracking app. Seems like this was working a few weeks ago?? Can we not just restore this widget to what was an excellent function in old Blynk? Ideas?

EDIT 2: The MyMAP widget from old Blynk seems to be missing another key function - clear. My code:

WidgetMap myMap(V7); // set up Map widget on Blynk
...
// This function is called whenever "erase markers" button on Map is pressed
BLYNK_WRITE(V40) {
  if (param.asInt()) {
    myMap.clear(); // erase any marker(s)
    Serial.print("Map GPS markers erased!");
  }
}

When I press the Blynk button linked to V40 my previously placed markers remain visible on the map. Thoughts? Thanks!

Unfortunately the current Map widget on mobile lacks the tracking features. We have it in plans (probably will be similar to web counterpart), but no eta.

This is how it works at the moment

The new, location type of datastream does not support clearing value in such way. In datastream settings there is an option to invalidate value after some time passed, if it helps.

At the moment the Map widget on mobile does some compatibility when used with a string type of datastream (the old way). It should support old format and “clr” command, but when device dashboard is opened only the last set marker will be shown without history.

Eugene, thanks so much for the detailed response! Just one quick question re your last comment…you said the Map widget does offer some compatibility when used with a string type of data stream. Can you please be more specific? Are you saying that I could pass the lat and lon as String datatypes? Not sure what you mean here as I have not used that feature with Blynk. A line or two of sample code would help a lot! Thanks!

I was talking about Datastream type. When creating a new datastream on the web, first selct “Virtual Pin” type, and then setup its data type to be “String”. When Map widget on mobile gets data from such datastream, it expects it to be in old (legacy) format. i.e.

Blynk.virtualWrite(pin, index, lat, lon, label)

Hi Eugene, thanks, this is working with my GPS! Appreciate the tip!!