0

Could someone help me translate it to angular directive?

var mapa;
var marker;

function mapaStart() {
mapOpc = {
    center: new google.maps.LatLng(52.348763181988076, 18.61083984375),
    zoom: 6,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
mapa = new google.maps.Map(document.getElementById("doMeeting"), mapOpc);

marker = new google.maps.Marker({
    position: new google.maps.LatLng(52.348763181988076, 18.61083984375),
    draggable: true,
    map: mapa,
});
marker.setMap(mapa);

// zdarzenia dla markera
google.maps.event.addListener(marker, 'drag', uaktualnijWspolrzedne);
google.maps.event.trigger(marker, 'drag');

// zdarzenia dla mapy
google.maps.event.addListener(mapa, 'click', function (event) {
    marker.setPosition(event.latLng);
    uaktualnijWspolrzedne();
});

}

function uaktualnijWspolrzedne() {
var input_lat = document.getElementById('lat');
var input_lng = document.getElementById('lng');
var punkt = marker.getPosition();

input_lat.value = punkt.lat();
input_lng.value = punkt.lng();
}
google.maps.event.addDomListener(window, 'load', mapaStart);

EDIT

Maybe it wasnt good idea to put in on jsfiddle becouse of configuration jsfiddle .

I put it in on plnkr to make it clear:

http://plnkr.co/edit/EyPOmok6vmvA6Cc2yQws?p=preview

But when i try to implement to my project i get blank border instead google map, (module Geolocation work)

1

2 Answers 2

0

Here is your updated Fiddle. There was a problem in the setup and ng-app was not initialized.

// just a comment
Sign up to request clarification or add additional context in comments.

Comments

0

Problem is in configuring JSFiddle, not in your code. You need to do:

  1. Remove angular.js script from resources
  2. Select angular.js from dropdown in Fiddle Options (under Frameworks & Extensions)
  3. Select options "No wrap - in head"

Explanations here: Simple AngularJS running on JSFiddle

2 Comments

Please look on my Edit
For me your plunkr works just fine. Probably you already fixed it )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.