Hank Joreid
Posts: 0
Joined: Mon Apr 20, 2015 1:00 pm

Select location with map

Hi,
1.
i think i have fixed the problem. but now i see if i dont change the marker i cant get the data from it. i need to move it one time before i get the user data, can we fix this?

2.
The map wont load before a long time. any way to fix this? its takes arraound 6-10 sec to load the map

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Select location with map

Hi Hank,

  1. In answer to your first question, when the marker initializes - it's getting its data (the location to start from) - from local storage. You've also developed a service I assume - when the marker is moved - to record the data in a collection. So - I'm assuming you would like to do that - when the marker is dropped on the map?

    If that's the case simply move a call to your service - into this Javascript that you have loaded....(Perhaps as the last line)

    function fmyMarkerInit() {
    // create a marker and make it draggable... and add a listener event for when it's dragged...
    var oposition = new google.maps.LatLng( localStorage.getItem('s_lat'), localStorage.getItem('s_long') );
    var oMarker = new google.maps.Marker({
    position: oposition, // a position object defined previiously
    map: oMyMap, // your map object
    draggable: true, // set the draggable property to true
    title: "Drag me to a new location", // title for the marker
    animation: google.maps.Animation.DROP,// remove if you want
    icon: 'http://maps.google.com/mapfiles/kml/p...' // not required
    });
    google.maps.event.addListener( oMarker , 'dragend', function( ) {
    console.log('moving marker with title: ' + oMarker.getTitle() );
    fmovemarker( oMarker );
    } );
    oGlobalMarker = oMarker;
    oMyMap.panTo( oposition );
    (name of your service to record location).execute();
    }

  2. When I run the same code - the map initializes in 1.5 seconds - however - I have the highest possible internet speed in my office from my provider. Since the code is waiting for the API call from google to complete - I'd say it's dependent on the speed of your internet connection. You can take a few millseconds out of the equation - by lowering the interval in this call (do not make it less than 100 in my opinion). But the most that will buy you will be 4/10ths of a second - and on average about .2 seconds. Here's where you can tweak the interval ... The 500 is 500 millseconds (1/2 a second) - check whether or not the map has finished initializing - you can change it to 100 if you like....

    function fInitMarker(){
    if (bMarkerDropped) { return ;}
    oMyMap = Appery("mapMyMap").options.mapElement.gmap('get', 'map');
    nTimerHandle = setInterval(function(){ fmyTimer(); }, 500);
    return;
    }

    Best,

    Bruce

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Select location with map

the code on this thread - for anyone elses benefit - gets you past the getbounds error you will get with the Appery Maps straight out of the box - in the current release.

Hank Joreid
Posts: 0
Joined: Mon Apr 20, 2015 1:00 pm

Select location with map

Hi agan Bruce!
Seems like the marker is stil a problem.
It spam down many markers at one.

How to fix this?

Image

Zahid
Posts: 0
Joined: Tue Oct 11, 2016 8:10 am

Select location with map

Hi Bruce,

The js file on this https://www.the-software-studio.com/j... link no more exists. Can you please provide the file? Thanks.

Return to “Issues”