Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue with native map and custom marker handled with custom map layout #2381

Closed
ramsestom opened this issue Apr 2, 2018 · 1 comment
Assignees
Milestone

Comments

@ramsestom
Copy link

When trying to render a custom marker component on top of a google map with a custom map layout (using the code of this blog post: https://www.codenameone.com/blog/map-layout-update.html), my marker position is lagging out (bounce effect) when I move the map.

Here is a short video to show the issue:
https://streamable.com/4rocw

What I was expecting is performances similar to the one achieved with react-native, where markers seems like part of the map image itself (I made a short video with a dynamic marker (just a counter that increment by 1 every second) to show you how this looks like in react-native using https://github.com/react-community/react-native-maps to render the map and a standard custom react-native component (javascript) for the marker):
https://streamable.com/ahtor

My CN1 map Form is extremely simple (It was just to test for now):

public class Map extends com.codename1.ui.Form {

	private static final String HTML_API_KEY = "I put my private API key here";
	
	public Map() 
	{
	setLayout(new BorderLayout());
      final MapContainer mc = new MapContainer(HTML_API_KEY);
     

      Container mrc = LayeredLayout.encloseIn(
              BorderLayout.center(mc)
      );

      add(BorderLayout.CENTER, mrc);
            
      Container markers = new Container();
      markers.setLayout(new MapLayout(mc, markers));
      mrc.add(markers);

      Coord moscone = new Coord(45.757350, 4.834434);
      Button mosconeButton = new Button("");
      FontImage.setMaterialIcon(mosconeButton, FontImage.MATERIAL_PLACE);
      markers.add(moscone, mosconeButton);

      mc.zoom(moscone, 20);
      }
}

As for my MapLayout class, the code is exactly the same as the one in this post: https://www.codenameone.com/blog/map-layout-update.html

This issue has already been discussed here:
http://www.codenameone.com/discussion-forum.html?place=topic%2Fcodenameone-discussions%2F6BghRd4sFNM%2Fdiscussion

@codenameone codenameone added this to the Version 5.0 milestone Apr 2, 2018
@shannah
Copy link
Collaborator

shannah commented Apr 5, 2018

I've moved the MapLayout inside the GoogleMaps cn1lib, and it shouldn't be necessary anymore as I've also added an API to add Components directly as markers in the MapContainer.
codenameone/codenameone-google-maps@614f77f

myMap.addMarker(myComponent, myCoord);

These components are converted directly into image markers when the map is being dragged so that they are effectively native markers. This resolves the latency issue.

@shannah shannah closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants