Hello,
I’ve been having tons of fun with Blynk lately. Thank you.
I’m using latest Blynk on Android with AssetTracker shield and Electron.
For some reason somewhere along my travel path a marker will remain at some random location. This will cause the map to remain focused on that position while the updated marker moves off the map. Hitting the lens again will scale the map to show both markers. I only want one marker. I have no idea why a second is created.
Here is my complete code. Sorry about the crappy formatting.
#include <blynk.h>
#include <google-maps-device-locator.h>
#include <AssetTracker.h>
#include <time.h>
#include <string.h>
#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG // Optional, this enables more detailed prints
SYSTEM_MODE(AUTOMATIC);
char auth[] = "EAT AT JOE's";
String symbol[] = {"/","—","\\","|"};
unsigned int pos = 0;
unsigned gpsLoop;
AssetTracker t = AssetTracker();
BlynkTimer Timer;
FuelGauge fuel;
WidgetLCD lcd(V4);
WidgetMap myMap(V0);
GoogleMapsDeviceLocator locator;
void setup() {
Serial.begin(9600);
Blynk.begin(auth);
t.begin();
t.gpsOn();
locator.withSubscribe(locationCallback).withLocateOnce();
gpsLoop = Timer.setInterval(15000L, myGPSUpdate);
Timer.enable(gpsLoop);
Time.zone(-8);
}
void loop() {
t.updateGPS();
Blynk.run();
Timer.run();
}
//update position
void myGPSUpdate(){
if(t.gpsFix()){
String LatLon1 = t.readLatLon();
float Lat1 = t.readLatDeg();
float Lon1 = t.readLonDeg();
unsigned int index = 1;
myMap.location(index, Lat1, Lon1, Time.format(Time.now(), "%I:%M%" ));
lcd.print(0,1, "Last GPS " + Time.format(Time.now(), "%I:%M%" ) + " " + symbol[pos]);
pos++;
if (pos >= 4){
pos = 0;
}
} else {locator.loop();}
}
//get battery health and write to LCD
BLYNK_WRITE(V2){
if ( param.asInt() ){
float lastBatt = fuel.getSoC();
float lastV = fuel.getVCell();
lcd.print(0,0, "Batt:" + String::format("%.2f", lastV) + "V " + String::format("%.1f",lastBatt) + "%");
}
}
//use slider to change reporting frequency from 300s to 5s to save data, default is 15s
BLYNK_WRITE(V1){
//String newtime = String::format("%u", param.asInt() ) + "L";
unsigned int val = param.asInt();
Timer.disable(gpsLoop);
gpsLoop = Timer.setInterval(val*1000L, myGPSUpdate);
Timer.enable(gpsLoop);
lcd.print(0,0, "Period: " + String::format("%u",val) + "s " );
}
//listen for GSM positions by Google API and update location
void locationCallback(float lat, float lon, float accuracy) {
int index = 1;
myMap.location(index, lat, lon, Time.format(Time.now(), "%I:%M%" ) );
lcd.print(0,1, "Cell Location " + symbol[pos] );
pos++;
if (pos >= 4){
pos = 0;
}
}

